Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person
- include ActiveModel::Serialization
- include ActiveModel::Serializers::JSON
- attr_accessor :name, :email
- def initialize(attributes = {})
- attributes.each do |name, value|
- send("#{name}=", value)
- end
- end
- def attributes
- {
- :name => @name,
- :email => @email
- }
- end
- def attributes=(params)
- params.each do |k,v|
- puts "#{k} : #{v}"
- send("#{k}=", v) if attributes.has_key? k.to_sym
- end
- end
- end
Add Comment
Please, Sign In to add comment