Sha256: b54717870df3e1ff273aeb39f3cff29da51dcb547681c03884b0869be93f3f8a

Contents?: true

Size: 964 Bytes

Versions: 2

Compression:

Stored size: 964 Bytes

Contents

module Her
  module Model
    module Associations
      class Association
        attr_accessor :query_attrs

        # @private
        def initialize(parent, opts = {})
          @parent = parent
          @opts = opts
          @query_attrs = {}

          @klass = @parent.class.her_nearby_class(@opts[:class_name])
          @name = @opts[:name]
        end

        def where(attrs = {})
          return self if attrs.blank?
          self.clone.tap { |a| a.query_attrs = a.query_attrs.merge(attrs) }
        end
        alias :all :where

        # @private
        def nil?
          fetch.nil?
        end

        # @private
        def kind_of?(thing)
          fetch.kind_of?(thing)
        end

        # @private
        def ==(other)
          fetch.eql?(other)
        end
        alias :eql? :==

        # @private
        def method_missing(method, *args, &blk)
          fetch.send(method, *args, &blk)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
her-0.6.1 lib/her/model/associations/association.rb
her-0.6 lib/her/model/associations/association.rb