Class: Sublayer::Components::OutputAdapters::StringSelectionFromList

Inherits:
Object
  • Object
show all
Defined in:
lib/sublayer/components/output_adapters/string_selection_from_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ StringSelectionFromList

Returns a new instance of StringSelectionFromList.



7
8
9
10
11
# File 'lib/sublayer/components/output_adapters/string_selection_from_list.rb', line 7

def initialize(options)
  @name = options[:name]
  @description = options[:description]
  @list = options[:options]
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/sublayer/components/output_adapters/string_selection_from_list.rb', line 5

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/sublayer/components/output_adapters/string_selection_from_list.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/sublayer/components/output_adapters/string_selection_from_list.rb', line 5

def options
  @options
end

Instance Method Details

#load_instance_data(generator) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/sublayer/components/output_adapters/string_selection_from_list.rb', line 17

def load_instance_data(generator)
  case @list
  when Proc
    @list = generator.instance_exec(&@list)
  when Symbol
    @list = generator.send(@list)
  else
    @list
  end
end

#propertiesObject



13
14
15
# File 'lib/sublayer/components/output_adapters/string_selection_from_list.rb', line 13

def properties
  [OpenStruct.new(name: @name, type: 'string', description: @description, required: true, enum: @list)]
end