Class: GlueGun::DSL::ConfigAttr
- Inherits:
-
Object
- Object
- GlueGun::DSL::ConfigAttr
- Defined in:
- lib/glue_gun/dsl.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(name, default: nil, required: false, source: nil, &block) ⇒ ConfigAttr
constructor
A new instance of ConfigAttr.
- #process_value(value, _context = nil) ⇒ Object
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
#block ⇒ Object (readonly)
Returns the value of attribute block.
299 300 301 |
# File 'lib/glue_gun/dsl.rb', line 299 def block @block end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
299 300 301 |
# File 'lib/glue_gun/dsl.rb', line 299 def default @default end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
299 300 301 |
# File 'lib/glue_gun/dsl.rb', line 299 def name @name end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
299 300 301 |
# File 'lib/glue_gun/dsl.rb', line 299 def required @required end |
#source ⇒ Object (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 |