Class: TaoForm::Components::MomentPicker::SegmentListComponent

Inherits:
TaoOnRails::Components::Base
  • Object
show all
Defined in:
lib/tao_form/components/moment_picker/segment_list_component.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, options = {}) ⇒ SegmentListComponent

Returns a new instance of SegmentListComponent.



8
9
10
11
12
# File 'lib/tao_form/components/moment_picker/segment_list_component.rb', line 8

def initialize view, options = {}
  super view, options
  @segments = @options.delete(:segments)
  init_segment_options
end

Instance Attribute Details

#segment_optionsObject (readonly)

Returns the value of attribute segment_options.



6
7
8
# File 'lib/tao_form/components/moment_picker/segment_list_component.rb', line 6

def segment_options
  @segment_options
end

#segmentsObject (readonly)

Returns the value of attribute segments.



6
7
8
# File 'lib/tao_form/components/moment_picker/segment_list_component.rb', line 6

def segments
  @segments
end

Class Method Details

.component_nameObject



31
32
33
# File 'lib/tao_form/components/moment_picker/segment_list_component.rb', line 31

def self.component_name
  :moment_picker_segment_list
end

Instance Method Details

#render_segment(segment) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tao_form/components/moment_picker/segment_list_component.rb', line 18

def render_segment segment
  if segment.is_a? Hash
    segment = segment.clone
    name = segment.delete(:name)
    opts = segment_options.merge segment
  else
    name = segment
    opts = segment_options
  end

  view.send :"tao_moment_picker_#{name}_segment", opts
end

#separator_segment?(segment) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/tao_form/components/moment_picker/segment_list_component.rb', line 14

def separator_segment? segment
  segment.is_a?(Hash) && segment[:separator].present?
end