module Her::Model::Associations
This module adds associations to models
Public Instance Methods
get_association(association_name)
click to toggle source
Returns the resource/collection corresponding to the association_name association.
@private
# File lib/castle-her/model/associations.rb, line 24 def get_association(association_name) send(association_name) if has_association?(association_name) end
has_association?(association_name)
click to toggle source
Returns true if the model has a association_name association, false otherwise.
@private
# File lib/castle-her/model/associations.rb, line 16 def has_association?(association_name) associations = self.class.associations.values.flatten.map { |r| r[:name] } associations.include?(association_name) end