class Consumerable::Associations::HasManyProxy
Attributes
parent[R]
source[R]
target[R]
target_klass[R]
Public Class Methods
new(parent, target_klass, target, source)
click to toggle source
# File lib/consumerable/associations/has_many_proxy.rb, line 7 def initialize(parent, target_klass, target, source) @parent = parent @target_klass = target_klass @target = target @source = source end
Public Instance Methods
build(attributes)
click to toggle source
# File lib/consumerable/associations/has_many_proxy.rb, line 22 def build(attributes) target_klass.new(attributes).tap do |item| item.send("#{source}=", parent) target << item end end
create(attributes = {})
click to toggle source
# File lib/consumerable/associations/has_many_proxy.rb, line 18 def create(attributes = {}) build(attributes).save end
method_missing(name, *args, &block)
click to toggle source
# File lib/consumerable/associations/has_many_proxy.rb, line 14 def method_missing(name, *args, &block) target.send(name, *args, &block) end
tap() { |self| ... }
click to toggle source
# File lib/consumerable/associations/has_many_proxy.rb, line 29 def tap yield self self end