Class: Flatter::Extension::Builder
- Inherits:
-
Object
- Object
- Flatter::Extension::Builder
- Defined in:
- lib/flatter/extension/builder.rb
Constant Summary collapse
- ExtensionBlockAlreadyDefined =
Class.new(RuntimeError)
Class Method Summary collapse
Instance Method Summary collapse
- #add_option(*options) ⇒ Object (also: #add_options)
- #extend(&block) ⇒ Object
- #extends? ⇒ Boolean
-
#initialize(ext) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(ext) ⇒ Builder
Returns a new instance of Builder.
13 14 15 16 |
# File 'lib/flatter/extension/builder.rb', line 13 def initialize(ext) @ext = ext @new_options = [] end |
Class Method Details
.extends(target_name) ⇒ Object
5 6 7 |
# File 'lib/flatter/extension/builder.rb', line 5 def self.extends(target_name) @target_name = target_name end |
.target_name ⇒ Object
9 10 11 |
# File 'lib/flatter/extension/builder.rb', line 9 def self.target_name @target_name end |
Instance Method Details
#add_option(*options) ⇒ Object Also known as: add_options
18 19 20 21 |
# File 'lib/flatter/extension/builder.rb', line 18 def add_option(*) @new_options.concat extend(&Proc.new) if block_given? end |
#extend(&block) ⇒ Object
24 25 26 27 |
# File 'lib/flatter/extension/builder.rb', line 24 def extend(&block) fail ExtensionBlockAlreadyDefined if @extension_block.present? @extension_block = block end |
#extends? ⇒ Boolean
29 30 31 |
# File 'lib/flatter/extension/builder.rb', line 29 def extends? @new_options.present? || @extension_block.present? end |