Sha256: ee570bfe7c59bbc97dbb5e0207c0122920975cdff345ff87bca6ea6b89af6ef2

Contents?: true

Size: 791 Bytes

Versions: 2

Compression:

Stored size: 791 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
    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

2 entries across 2 versions & 1 rubygems

Version Path
nay-record_with_operator-0.0.10 lib/association_with_operator.rb
nay-record_with_operator-0.0.9 lib/association_with_operator.rb