Class: Indexers::Dsl::Api
- Inherits:
-
Object
- Object
- Indexers::Dsl::Api
- Defined in:
- lib/indexers/dsl/api.rb
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 |
# 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) = args. name = name.to_sym if block_given? add_block name, args, , &block elsif args.size > 0 add_argument name, args, elsif .any? name, else add_empty name end end |
Instance Method Details
#to_h ⇒ Object
24 25 26 |
# File 'lib/indexers/dsl/api.rb', line 24 def to_h @parent end |