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.



98
99
100
101
# File 'lib/creditario/resources/resource.rb', line 98

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.



105
106
107
108
# File 'lib/creditario/resources/resource.rb', line 105

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