Guest User

Untitled

a guest
Nov 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. class Person
  2. include ActiveModel::Serialization
  3. include ActiveModel::Serializers::JSON
  4.  
  5. attr_accessor :name, :email
  6.  
  7. def initialize(attributes = {})
  8. attributes.each do |name, value|
  9. send("#{name}=", value)
  10. end
  11. end
  12.  
  13. def attributes
  14. {
  15. :name => @name,
  16. :email => @email
  17. }
  18. end
  19.  
  20. def attributes=(params)
  21. params.each do |k,v|
  22. puts "#{k} : #{v}"
  23. send("#{k}=", v) if attributes.has_key? k.to_sym
  24. end
  25. end
  26.  
  27. end
Add Comment
Please, Sign In to add comment