Class: FluQ::DSL::Options

Inherits:
BasicObject
Defined in:
lib/fluq/dsl/options.rb

Instance Method Summary collapse

Constructor Details

#initialize { ... } ⇒ Options

Constructor

Yields:

  • options assigment



5
6
7
8
# File 'lib/fluq/dsl/options.rb', line 5

def initialize(&block)
  @opts = {}
  instance_eval(&block) if block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (protected)



17
18
19
20
21
22
23
24
25
# File 'lib/fluq/dsl/options.rb', line 17

def method_missing(name, *args, &block)
  value = args[0]
  if value && block
    @opts[name.to_sym] = value
    @opts[:"#{name}_options"] = ::FluQ::DSL::Options.new(&block).to_hash
  else
    @opts[name.to_sym] = value || block || true
  end
end

Instance Method Details

#to_hashHash

Returns options hash.

Returns:

  • (Hash)

    options hash



11
12
13
# File 'lib/fluq/dsl/options.rb', line 11

def to_hash
  @opts
end