Class: BasicAssumption::DefaultAssumption::OwnerAttributes
- Inherits:
-
Object
- Object
- BasicAssumption::DefaultAssumption::OwnerAttributes
- Defined in:
- lib/basic_assumption/default_assumption/owner_attributes.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#owner_context ⇒ Object
readonly
Returns the value of attribute owner_context.
-
#owner_method ⇒ Object
readonly
Returns the value of attribute owner_method.
Instance Method Summary collapse
- #attributes ⇒ Object
- #column_name ⇒ Object
-
#initialize(owner_method_or_context, controller) ⇒ OwnerAttributes
constructor
A new instance of OwnerAttributes.
- #owner_object ⇒ Object
Constructor Details
#initialize(owner_method_or_context, controller) ⇒ OwnerAttributes
Returns a new instance of OwnerAttributes.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/basic_assumption/default_assumption/owner_attributes.rb', line 6 def initialize(owner_method_or_context, controller) @controller = controller if owner_method_or_context.kind_of? Hash @owner_method = owner_method_or_context[:object] @owner_context = owner_method_or_context else @owner_method = owner_method_or_context @owner_context = {} end end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
4 5 6 |
# File 'lib/basic_assumption/default_assumption/owner_attributes.rb', line 4 def controller @controller end |
#owner_context ⇒ Object (readonly)
Returns the value of attribute owner_context.
4 5 6 |
# File 'lib/basic_assumption/default_assumption/owner_attributes.rb', line 4 def owner_context @owner_context end |
#owner_method ⇒ Object (readonly)
Returns the value of attribute owner_method.
4 5 6 |
# File 'lib/basic_assumption/default_assumption/owner_attributes.rb', line 4 def owner_method @owner_method end |
Instance Method Details
#attributes ⇒ Object
18 19 20 |
# File 'lib/basic_assumption/default_assumption/owner_attributes.rb', line 18 def attributes {column_name => owner_object.id} end |
#column_name ⇒ Object
30 31 32 |
# File 'lib/basic_assumption/default_assumption/owner_attributes.rb', line 30 def column_name owner_context[:column_name] || :"#{owner_object.class.name.downcase}_id" end |
#owner_object ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/basic_assumption/default_assumption/owner_attributes.rb', line 22 def owner_object if owner_method.respond_to? :call controller.instance_eval(&owner_method) else controller.send(owner_method) end end |