Class: GlueGun::DSL::OptionBuilder
- Inherits:
-
Object
- Object
- GlueGun::DSL::OptionBuilder
- Defined in:
- lib/glue_gun/dsl.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#is_default ⇒ Object
readonly
Returns the value of attribute is_default.
-
#is_only ⇒ Object
readonly
Returns the value of attribute is_only.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #bind_attribute(name, default: nil, required: false, source: nil, &block) ⇒ Object
- #default ⇒ Object
-
#initialize(name) ⇒ OptionBuilder
constructor
A new instance of OptionBuilder.
- #only ⇒ Object
- #only? ⇒ Boolean
- #set_class(name) ⇒ Object
Constructor Details
#initialize(name) ⇒ OptionBuilder
Returns a new instance of OptionBuilder.
562 563 564 565 566 |
# File 'lib/glue_gun/dsl.rb', line 562 def initialize(name) @name = name @attributes = {} @is_default = false end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
560 561 562 |
# File 'lib/glue_gun/dsl.rb', line 560 def attributes @attributes end |
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
560 561 562 |
# File 'lib/glue_gun/dsl.rb', line 560 def class_name @class_name end |
#is_default ⇒ Object (readonly)
Returns the value of attribute is_default.
560 561 562 |
# File 'lib/glue_gun/dsl.rb', line 560 def is_default @is_default end |
#is_only ⇒ Object (readonly)
Returns the value of attribute is_only.
560 561 562 |
# File 'lib/glue_gun/dsl.rb', line 560 def is_only @is_only end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
560 561 562 |
# File 'lib/glue_gun/dsl.rb', line 560 def name @name end |
Instance Method Details
#bind_attribute(name, default: nil, required: false, source: nil, &block) ⇒ Object
578 579 580 581 |
# File 'lib/glue_gun/dsl.rb', line 578 def bind_attribute(name, default: nil, required: false, source: nil, &block) attr = ConfigAttr.new(name, default: default, required: required, source: source, &block) @attributes[name.to_sym] = attr end |
#default ⇒ Object
583 584 585 |
# File 'lib/glue_gun/dsl.rb', line 583 def default @is_default = true end |
#only ⇒ Object
587 588 589 |
# File 'lib/glue_gun/dsl.rb', line 587 def only @is_only = true end |
#only? ⇒ Boolean
591 592 593 |
# File 'lib/glue_gun/dsl.rb', line 591 def only? @is_only == true end |
#set_class(name) ⇒ Object
568 569 570 571 572 573 574 575 576 |
# File 'lib/glue_gun/dsl.rb', line 568 def set_class(name) if name.is_a?(Class) @class_name = name elsif name.is_a?(String) @class_name = name.constantize else raise "Class name #{name} must be a string or class. Cannot find #{name}." end end |