class Brainstem::DSL::Association
Attributes
name[R]
options[R]
target_class[R]
Public Class Methods
new(name, target_class, options)
click to toggle source
# File lib/brainstem/dsl/association.rb, line 10 def initialize(name, target_class, options) @name = name.to_s @target_class = target_class @options = options end
Public Instance Methods
always_return_ref_with_sti_base?()
click to toggle source
# File lib/brainstem/dsl/association.rb, line 59 def always_return_ref_with_sti_base? options[:always_return_ref_with_sti_base] end
description()
click to toggle source
# File lib/brainstem/dsl/association.rb, line 16 def description options[:info].presence end
method_name()
click to toggle source
# File lib/brainstem/dsl/association.rb, line 32 def method_name if options[:dynamic] || options[:lookup] nil else (options[:via].presence || name).to_s end end
polymorphic?()
click to toggle source
# File lib/brainstem/dsl/association.rb, line 55 def polymorphic? target_class == :polymorphic end
polymorphic_classes()
click to toggle source
# File lib/brainstem/dsl/association.rb, line 24 def polymorphic_classes options[:polymorphic_classes] end
response_key()
click to toggle source
# File lib/brainstem/dsl/association.rb, line 20 def response_key options[:response_key] end
run_on(model, context, helper_instance = Object.new)
click to toggle source
# File lib/brainstem/dsl/association.rb, line 40 def run_on(model, context, helper_instance = Object.new) if options[:lookup] run_on_with_lookup(model, context, helper_instance) elsif options[:dynamic] proc = options[:dynamic] if proc.arity == 1 helper_instance.instance_exec(model, &proc) else helper_instance.instance_exec(&proc) end else model.send(method_name) end end
type()
click to toggle source
# File lib/brainstem/dsl/association.rb, line 28 def type options[:type] end
Private Instance Methods
key_for_lookup()
click to toggle source
# File lib/brainstem/dsl/association.rb, line 65 def key_for_lookup :associations end