Class: Yaoc::ConverterBuilder
- Inherits:
-
Object
- Object
- Yaoc::ConverterBuilder
- Includes:
- BuilderDSLMethods
- Defined in:
- lib/yaoc/converter_builder.rb
Instance Attribute Summary collapse
-
#all_commands_applied ⇒ Object
Returns the value of attribute all_commands_applied.
-
#build_commands ⇒ Object
Returns the value of attribute build_commands.
-
#command_order ⇒ Object
Returns the value of attribute command_order.
-
#strategy ⇒ Object
Returns the value of attribute strategy.
Instance Method Summary collapse
- #apply_commands! ⇒ Object
- #converter(fetch_able, target_source = nil) ⇒ Object
- #fetcher=(new_fetcher) ⇒ Object
-
#initialize(command_order = :recorded_order, fetcher = :fetch) ⇒ ConverterBuilder
constructor
A new instance of ConverterBuilder.
Methods included from BuilderDSLMethods
#add_mapping, #build_commands_ordered, #fetch_with, #noop, #rule, #with_strategy
Constructor Details
#initialize(command_order = :recorded_order, fetcher = :fetch) ⇒ ConverterBuilder
Returns a new instance of ConverterBuilder.
93 94 95 96 97 98 99 |
# File 'lib/yaoc/converter_builder.rb', line 93 def initialize(command_order = :recorded_order, fetcher = :fetch) self.build_commands = [] self.command_order = command_order self.fetcher = fetcher self.strategy = :to_hash_mapping self.all_commands_applied = false end |
Instance Attribute Details
#all_commands_applied ⇒ Object
Returns the value of attribute all_commands_applied.
90 91 92 |
# File 'lib/yaoc/converter_builder.rb', line 90 def all_commands_applied @all_commands_applied end |
#build_commands ⇒ Object
Returns the value of attribute build_commands.
90 91 92 |
# File 'lib/yaoc/converter_builder.rb', line 90 def build_commands @build_commands end |
#command_order ⇒ Object
Returns the value of attribute command_order.
90 91 92 |
# File 'lib/yaoc/converter_builder.rb', line 90 def command_order @command_order end |
#strategy ⇒ Object
Returns the value of attribute strategy.
90 91 92 |
# File 'lib/yaoc/converter_builder.rb', line 90 def strategy @strategy end |
Instance Method Details
#apply_commands! ⇒ Object
101 102 103 104 105 106 |
# File 'lib/yaoc/converter_builder.rb', line 101 def apply_commands! reset_converters! self.all_commands_applied = true build_commands_ordered.each &:call end |
#converter(fetch_able, target_source = nil) ⇒ Object
108 109 110 111 |
# File 'lib/yaoc/converter_builder.rb', line 108 def converter(fetch_able, target_source = nil) fail 'BuildCommandsNotExecuted' unless self.all_commands_applied? converter_class.new(fetch_able, fetcher, target_source || ->(attrs) { attrs }) end |
#fetcher=(new_fetcher) ⇒ Object
113 114 115 |
# File 'lib/yaoc/converter_builder.rb', line 113 def fetcher=(new_fetcher) @fetcher = new_fetcher end |