Class: Rake::Funnel::Support::Mapper
- Inherits:
-
Object
- Object
- Rake::Funnel::Support::Mapper
- Includes:
- ArgumentMapper, InstantiateSymbol
- Defined in:
- lib/rake/funnel/support/mapper.rb
Instance Method Summary collapse
-
#initialize(style = :default) ⇒ Mapper
constructor
A new instance of Mapper.
- #map(args = {}) ⇒ Object
Methods included from InstantiateSymbol
Constructor Details
#initialize(style = :default) ⇒ Mapper
Returns a new instance of Mapper.
13 14 15 16 17 |
# File 'lib/rake/funnel/support/mapper.rb', line 13 def initialize(style = :default) raise "You cannot use the 'nil' mapper style. Available mappers are: #{available.inspect}" if style.nil? @style = create(style) end |
Instance Method Details
#map(args = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rake/funnel/support/mapper.rb', line 19 def map(args = {}) model = (args || {}).map { |switch, value| value = [value] unless value.is_a?(Array) values = value.map do |val| get_values(val) end Switch.new(switch, values) }.flatten @style .generate_from(model) .map { |args| args.map { |arg| camel_case_symbols(arg) } } .map(&:join) end |