Sha256: b5f970819828a6eb05d154ff07d9f5ddbb2ea7ae45bdf8c881d877773e37421a

Contents?: true

Size: 802 Bytes

Versions: 6

Compression:

Stored size: 802 Bytes

Contents

module AssociationWithOperator

  def find(*args)
    results = super
    if results.kind_of? Array
      results.each{|r| r.operator = proxy_owner.operator}
    else
      results.operator = proxy_owner.operator if results
    end
    results
  end


  def method_missing(method, *args)
    results = super
    if results.respond_to?(:operator=)
      results.operator= proxy_owner.operator
    elsif results.kind_of? Array
      results.each{|r| r.operator = proxy_owner.operator if r.respond_to?(:operator=)}
    end
    results
  end

  def construct_join_attributes(associate)
    join_attributes = super
    if @owner.operator || associate.operator
      join_attributes[:operator] ||= @owner.operator
      join_attributes[:operator] ||= associate.operator
    end
    join_attributes
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nay-record_with_operator-0.0.11 lib/association_with_operator.rb
nay-record_with_operator-0.0.14 lib/association_with_operator.rb
nay-record_with_operator-0.0.16 lib/association_with_operator.rb
nay-record_with_operator-0.0.17 lib/association_with_operator.rb
nay-record_with_operator-0.0.18 lib/association_with_operator.rb
nay-record_with_operator-0.0.19 lib/association_with_operator.rb