Module: Creditario::Resource::ClassMethods

Defined in:
lib/creditario/resources/resource.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#has_many(*association) ⇒ Object

Define una relación de uno a muchos con otro recurso.



94
95
96
97
# File 'lib/creditario/resources/resource.rb', line 94

def has_many(*association)
  self.class_variable_set(:@@associations, []) unless self.class_variable_defined?(:@@associations)
  self.class_variable_get(:@@associations) << { name: association.first }.merge(association.last)
end

#has_one(*association) ⇒ Object

Define una relacion de uno a uno con otro recurso.



101
102
103
104
# File 'lib/creditario/resources/resource.rb', line 101

def has_one(*association)
  self.class_variable_set(:@@associations, []) unless self.class_variable_defined?(:@@associations)
  self.class_variable_get(:@@associations) << { name: association.first }.merge(association.last)
end