Sha256: 9d7275b0f335be45bad95bdd6e60cf4a2f5028d90f6c9ba0a3a8eed349dba4b5

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

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

        # Add query parameters to the HTTP request performed to fetch the data
        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? ==

        # ruby 1.8.7 compatibility
        # @private
        def id
          fetch.id
        end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
her-0.6.3 lib/her/model/associations/association.rb