Class: Mockolate::Request::DSL
- Inherits:
-
Object
- Object
- Mockolate::Request::DSL
- Defined in:
- lib/mockolate/request.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #hash(*args, &block) ⇒ Object
-
#initialize(options) ⇒ DSL
constructor
A new instance of DSL.
- #method_missing(type, *args, &block) ⇒ Object
Constructor Details
#initialize(options) ⇒ DSL
Returns a new instance of DSL.
39 40 41 42 |
# File 'lib/mockolate/request.rb', line 39 def initialize() @attributes = [] @options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(type, *args, &block) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mockolate/request.rb', line 49 def method_missing(type, *args, &block) = Mockolate::Register.get(type) field_name = args.first = args[1] attibute = .create(name: field_name, options: ) if block_given? attibute.children = Mockolate::Request.payload_parser(, &block) end attributes << attibute end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
36 37 38 |
# File 'lib/mockolate/request.rb', line 36 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
37 38 39 |
# File 'lib/mockolate/request.rb', line 37 def @options end |
Instance Method Details
#hash(*args, &block) ⇒ Object
44 45 46 47 |
# File 'lib/mockolate/request.rb', line 44 def hash(*args, &block) raise Mockolate::Errors::MissingHashBlockError unless block_given? method_missing(:hash, *args, &block) end |