Class: Indices::Dsl::Api
- Inherits:
-
Object
- Object
- Indices::Dsl::Api
- Defined in:
- lib/indices/dsl/api.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(args = [], parent = {}, &block) ⇒ Api
constructor
A new instance of Api.
- #method_missing(name, *args, &block) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(args = [], parent = {}, &block) ⇒ Api
Returns a new instance of Api.
5 6 7 8 9 |
# File 'lib/indices/dsl/api.rb', line 5 def initialize(args=[], parent={}, &block) @args = args @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
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/indices/dsl/api.rb', line 11 def method_missing(name, *args, &block) = args. name = name.to_sym if block_given? child = add_block(name, args, ) continue child, &block elsif args.size > 0 add_argument name, args, elsif .any? name, else add_empty name end end |
Instance Method Details
#to_h ⇒ Object
26 27 28 |
# File 'lib/indices/dsl/api.rb', line 26 def to_h @parent end |