Class: Subroutine::Outputs::Configuration

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/subroutine/outputs/configuration.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{ required: true }.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_name, config) ⇒ Configuration

Returns a new instance of Configuration.



20
21
22
23
# File 'lib/subroutine/outputs/configuration.rb', line 20

def initialize(output_name, config)
  @output_name = output_name
  super(DEFAULT_OPTIONS.merge(config))
end

Instance Attribute Details

#output_nameObject (readonly)

Returns the value of attribute output_name.



18
19
20
# File 'lib/subroutine/outputs/configuration.rb', line 18

def output_name
  @output_name
end

Class Method Details

.from(field_name, options) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/subroutine/outputs/configuration.rb', line 7

def self.from(field_name, options)
  case options
  when Subroutine::Outputs::Configuration
    options.class.new(field_name, options)
  else
    new(field_name, options)
  end
end

Instance Method Details

#inspectObject



31
32
33
# File 'lib/subroutine/outputs/configuration.rb', line 31

def inspect
  "#<#{self.class}:#{object_id} name=#{output_name} config=#{config.inspect}>"
end

#required?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/subroutine/outputs/configuration.rb', line 27

def required?
  !!config[:required]
end