Class: GraphQL::Rails::DSL
- Inherits:
- BasicObject
- Defined in:
- lib/graphql/rails/dsl.rb
Overview
Object that runs a block in the context of itself, but delegates unknown methods back to the block’s original context. This is useful for creating DSLs to aid with object initialization.
Note that this class extends from BasicObject, which means that all global classes and modules must be prefixed by a double-colon (::) in order to resolve.
Direct Known Subclasses
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
18 19 20 21 22 23 24 |
# File 'lib/graphql/rails/dsl.rb', line 18 def method_missing(method, *args, &block) begin @self.send(method, *args, &block) rescue super end end |
Instance Method Details
#run(&block) ⇒ Object
11 12 13 14 |
# File 'lib/graphql/rails/dsl.rb', line 11 def run(&block) @self = eval('self', block.binding) instance_eval(&block) end |