Class: Sirens::ColumnProps
- Inherits:
-
Object
- Object
- Sirens::ColumnProps
- Defined in:
- lib/components_builder/column_props.rb
Instance Attribute Summary collapse
-
#props ⇒ Object
readonly
Returns the value of attribute props.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #display_image_of(item) ⇒ Object
- #display_text_of(item) ⇒ Object
- #fetch(key, absent_value) ⇒ Object
- #has_image_block? ⇒ Boolean
- #has_text_block? ⇒ Boolean
-
#initialize(props = Hash[]) ⇒ ColumnProps
constructor
A new instance of ColumnProps.
Constructor Details
#initialize(props = Hash[]) ⇒ ColumnProps
Returns a new instance of ColumnProps.
3 4 5 |
# File 'lib/components_builder/column_props.rb', line 3 def initialize(props = Hash[]) @props = props end |
Instance Attribute Details
#props ⇒ Object (readonly)
Returns the value of attribute props.
7 8 9 |
# File 'lib/components_builder/column_props.rb', line 7 def props @props end |
Instance Method Details
#[](key) ⇒ Object
21 22 23 |
# File 'lib/components_builder/column_props.rb', line 21 def [](key) @props[key] end |
#display_image_of(item) ⇒ Object
31 32 33 |
# File 'lib/components_builder/column_props.rb', line 31 def display_image_of(item) @props[:get_image_block].call(item) end |
#display_text_of(item) ⇒ Object
25 26 27 28 29 |
# File 'lib/components_builder/column_props.rb', line 25 def display_text_of(item) return item.to_s if ! has_text_block? @props[:get_text_block].call(item) end |
#fetch(key, absent_value) ⇒ Object
17 18 19 |
# File 'lib/components_builder/column_props.rb', line 17 def fetch(key, absent_value) @props.fetch(key, absent_value) end |
#has_image_block? ⇒ Boolean
9 10 11 |
# File 'lib/components_builder/column_props.rb', line 9 def has_image_block?() @props.key?(:get_image_block) end |
#has_text_block? ⇒ Boolean
13 14 15 |
# File 'lib/components_builder/column_props.rb', line 13 def has_text_block?() @props.key?(:get_text_block) end |