Class: Phlexi::Table::WrappedObject
- Inherits:
-
Object
- Object
- Phlexi::Table::WrappedObject
- Defined in:
- lib/phlexi/table/wrapped_object.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#unwrapped ⇒ Object
readonly
Returns the value of attribute unwrapped.
Instance Method Summary collapse
- #as_display ⇒ Object
- #identifier ⇒ Object
-
#initialize(object, index:, display_class:) ⇒ WrappedObject
constructor
A new instance of WrappedObject.
- #value_of(key) ⇒ Object
Constructor Details
#initialize(object, index:, display_class:) ⇒ WrappedObject
Returns a new instance of WrappedObject.
8 9 10 11 12 |
# File 'lib/phlexi/table/wrapped_object.rb', line 8 def initialize(object, index:, display_class:) @unwrapped = object @index = index @display_class = display_class end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
4 5 6 |
# File 'lib/phlexi/table/wrapped_object.rb', line 4 def index @index end |
#unwrapped ⇒ Object (readonly)
Returns the value of attribute unwrapped.
4 5 6 |
# File 'lib/phlexi/table/wrapped_object.rb', line 4 def unwrapped @unwrapped end |
Instance Method Details
#as_display ⇒ Object
22 23 24 |
# File 'lib/phlexi/table/wrapped_object.rb', line 22 def as_display @as_display ||= @display_class.new(unwrapped) end |
#identifier ⇒ Object
14 15 16 |
# File 'lib/phlexi/table/wrapped_object.rb', line 14 def identifier @identifier ||= Phlexi::Field.object_primary_key(unwrapped) || (index + 1) end |
#value_of(key) ⇒ Object
18 19 20 |
# File 'lib/phlexi/table/wrapped_object.rb', line 18 def value_of(key) @unwrapped.try(key) end |