Class: GlueGun::DSL::ConfigAttr

Inherits:
Object
  • Object
show all
Defined in:
lib/glue_gun/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, default: nil, required: false, source: nil, &block) ⇒ ConfigAttr

Returns a new instance of ConfigAttr.



301
302
303
304
305
306
307
# File 'lib/glue_gun/dsl.rb', line 301

def initialize(name, default: nil, required: false, source: nil, &block)
  @name = name.to_sym
  @default = default
  @required = required
  @source = source
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



299
300
301
# File 'lib/glue_gun/dsl.rb', line 299

def block
  @block
end

#defaultObject (readonly)

Returns the value of attribute default.



299
300
301
# File 'lib/glue_gun/dsl.rb', line 299

def default
  @default
end

#nameObject (readonly)

Returns the value of attribute name.



299
300
301
# File 'lib/glue_gun/dsl.rb', line 299

def name
  @name
end

#requiredObject (readonly)

Returns the value of attribute required.



299
300
301
# File 'lib/glue_gun/dsl.rb', line 299

def required
  @required
end

#sourceObject (readonly)

Returns the value of attribute source.



299
300
301
# File 'lib/glue_gun/dsl.rb', line 299

def source
  @source
end

Instance Method Details

#process_value(value, _context = nil) ⇒ Object



309
310
311
312
313
314
# File 'lib/glue_gun/dsl.rb', line 309

def process_value(value, _context = nil)
  value = evaluate_value(value)
  value = evaluate_value(@default) if value.nil? && !@default.nil?
  value = @block.call(value) if @block && !value.nil?
  value
end