Sha256: 6e47dfc27e1c713b333b03408e9bf61630a3a4438bbc2bbbfb08dc1758a0d330

Contents?: true

Size: 525 Bytes

Versions: 13

Compression:

Stored size: 525 Bytes

Contents

require "spira/association_reflection"

module Spira
  module Reflections
    # Returns a hash containing all AssociationReflection objects for the current class
    # Example:
    #
    #   Invoice.reflections
    #   Account.reflections
    #
    def reflections
      read_inheritable_attribute(:reflections) || write_inheritable_attribute(:reflections, {})
    end

    def reflect_on_association(association)
      reflections[association].is_a?(AssociationReflection) ? reflections[association] : nil
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
spira-3.3.0 lib/spira/reflections.rb
spira-3.2.0 lib/spira/reflections.rb
spira-3.1.1 lib/spira/reflections.rb
spira-3.1.0 lib/spira/reflections.rb
spira-3.0.0 lib/spira/reflections.rb
spira-2.1.0 lib/spira/reflections.rb
spira-2.0.2 lib/spira/reflections.rb
spira-2.0.1 lib/spira/reflections.rb
spira-2.0.0 lib/spira/reflections.rb
spira-1.1.1 lib/spira/reflections.rb
spira-0.7.1 lib/spira/reflections.rb
spira-0.7 lib/spira/reflections.rb
spira-0.5.0 lib/spira/reflections.rb