Class: Indexers::Dsl::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/indexers/dsl/api.rb

Direct Known Subclasses

Mappings, Traitable

Instance Method Summary collapse

Constructor Details

#initialize(args = [], parent = {}, &block) ⇒ Api

Returns a new instance of Api.



5
6
7
8
# File 'lib/indexers/dsl/api.rb', line 5

def initialize(args=[], parent={}, &block)
  @parent = parent
  instance_exec *args, &block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/indexers/dsl/api.rb', line 10

def method_missing(name, *args, &block)
  options = args.extract_options!
  name = name.to_sym
  if block_given?
    add_block name, args, options, &block
  elsif args.size > 0
    add_argument name, args, options
  elsif options.any?
    add_options name, options
  else
    add_empty name
  end
end

Instance Method Details

#to_hObject



24
25
26
# File 'lib/indexers/dsl/api.rb', line 24

def to_h
  @parent
end