Sha256: 3777b02ced9126d7141a04ba72878f31901b2ca776b6da149e8c8cea864b1429

Contents?: true

Size: 554 Bytes

Versions: 4

Compression:

Stored size: 554 Bytes

Contents

module Morpheus
  module Reflections

    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods

      def create_reflection(macro, name, options)
        Reflection.new(macro, name, options).tap do |reflection|
          reflections.merge!(name => reflection)
        end
      end

      def reflections
        @reflections ||= {}
      end

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

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
morpheus-0.4.0 lib/morpheus/mixins/reflections.rb
morpheus-0.3.9 lib/morpheus/mixins/reflections.rb
morpheus-0.3.8 lib/morpheus/mixins/reflections.rb
morpheus-0.3.7 lib/morpheus/mixins/reflections.rb