Class: Shipit::VariableDefinition

Inherits:
Object
  • Object
show all
Defined in:
app/models/shipit/variable_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ VariableDefinition

Returns a new instance of VariableDefinition.



7
8
9
10
11
12
13
# File 'app/models/shipit/variable_definition.rb', line 7

def initialize(attributes)
  @name = attributes.fetch('name')
  @title = attributes['title']
  @default = attributes['default'].to_s
  @default_provided = attributes.key?('default')
  @select = attributes['select'].presence
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



5
6
7
# File 'app/models/shipit/variable_definition.rb', line 5

def default
  @default
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'app/models/shipit/variable_definition.rb', line 5

def name
  @name
end

#selectObject (readonly)

Returns the value of attribute select.



5
6
7
# File 'app/models/shipit/variable_definition.rb', line 5

def select
  @select
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'app/models/shipit/variable_definition.rb', line 5

def title
  @title
end

Instance Method Details

#default_provided?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/models/shipit/variable_definition.rb', line 15

def default_provided?
  @default_provided
end

#to_hObject



19
20
21
22
23
24
25
26
# File 'app/models/shipit/variable_definition.rb', line 19

def to_h
  {
    'name' => @name,
    'title' => @title,
    'default' => @default,
    'select' => @select
  }
end