Module: JSONAPI::Consumer::Resource::AssociationConcern

Extended by:
ActiveSupport::Concern
Included in:
JSONAPI::Consumer::Resource
Defined in:
lib/jsonapi/consumer/resource/association_concern.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#association_namesArray<Symbol>

Helper method that returns the names of defined associations.

Returns:

  • (Array<Symbol>)

    a list of association names



124
125
126
# File 'lib/jsonapi/consumer/resource/association_concern.rb', line 124

def association_names
  self.class._associations.keys
end

#each_association(&block) ⇒ Object

:nodoc:



111
112
113
114
115
116
117
118
119
# File 'lib/jsonapi/consumer/resource/association_concern.rb', line 111

def each_association(&block)
  self.class._associations.dup.each do |name, options|
    association = self.send(name)

    if block_given?
      block.call(name, association, options[:options])
    end
  end
end