Class: GlueGun::DSL::OptionBuilder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject (readonly)

Returns the value of attribute attributes.



560
561
562
# File 'lib/glue_gun/dsl.rb', line 560

def attributes
  @attributes
end

#class_nameObject (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_defaultObject (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_onlyObject (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

#nameObject (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

#defaultObject



583
584
585
# File 'lib/glue_gun/dsl.rb', line 583

def default
  @is_default = true
end

#onlyObject



587
588
589
# File 'lib/glue_gun/dsl.rb', line 587

def only
  @is_only = true
end

#only?Boolean

Returns:

  • (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