Class: Sirens::ColumnProps

Inherits:
Object
  • Object
show all
Defined in:
lib/components_builder/column_props.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#propsObject (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

Returns:

  • (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

Returns:

  • (Boolean)


13
14
15
# File 'lib/components_builder/column_props.rb', line 13

def has_text_block?()
    @props.key?(:get_text_block)
end