Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods from included module which conflict with methods from the model don't work. #130

Open
AllanQ opened this issue Dec 4, 2018 · 1 comment

Comments

@AllanQ
Copy link

AllanQ commented Dec 4, 2018

I defined several serializers for one object.
Then I moved shared methods to a module and they aren't called.
Methods from the model are called instead.

class Person < ApplicationRecord
  attr_accessor :name, :lastname
end


class PersonSerializer < Surrealist::Serializer
  include PersonMethods

  alias person object

  json_schema { { name: String } }

  # def name
  #   "#{person.name} #{person.lastname}"
  # end
end


module PersonMethods
  def name
    "#{person.name} #{person.lastname}
  end
end
PersonSerializer.new(Person.new(name: "John", lastname: "Smith")).build_schema
=> {:name=>"John"}
@nesaulov
Copy link
Owner

Yep, that's a bug, thank you for reporting. I'd appreciate any help on this btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants