Class: Flatter::Extension::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/flatter/extension/builder.rb

Direct Known Subclasses

Factory, Mapper, Mapping

Constant Summary collapse

ExtensionBlockAlreadyDefined =
Class.new(RuntimeError)

Class Method Summary collapse

Instance Method Summary collapse

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_nameObject



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(*options)
  @new_options.concat options
  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

Returns:

  • (Boolean)


29
30
31
# File 'lib/flatter/extension/builder.rb', line 29

def extends?
  @new_options.present? || @extension_block.present?
end