Module: Packet::Entity::Associations::ClassMethods
- Defined in:
- lib/packet/entity/associations.rb
Instance Method Summary collapse
Instance Method Details
#has_many(association) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/packet/entity/associations.rb', line 18 def has_many(association) require "packet/#{association.to_s.singularize}" casts(association, lambda do |value| klass = "Packet::#{association.to_s.classify}".constantize value.map { |v| klass.new(v, client) } end) end |
#has_one(association) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/packet/entity/associations.rb', line 10 def has_one(association) require "packet/#{association}" casts(association, lambda do |value| klass = "Packet::#{association.to_s.classify}".constantize klass.new(value, client) end) end |