Class: Restspec::Endpoints::EndpointDSL
- Inherits:
-
Struct
- Object
- Struct
- Restspec::Endpoints::EndpointDSL
- Defined in:
- lib/restspec/endpoints/dsl.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
Instance Method Summary collapse
- #headers ⇒ Object
- #method(method) ⇒ Object
- #path(path) ⇒ Object
- #schema(name, schema_extensions = {}) ⇒ Object
- #url_param(param, &value_or_type_block) ⇒ Object
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint
89 90 91 |
# File 'lib/restspec/endpoints/dsl.rb', line 89 def endpoint @endpoint end |
Instance Method Details
#headers ⇒ Object
103 104 105 |
# File 'lib/restspec/endpoints/dsl.rb', line 103 def headers endpoint.headers end |
#method(method) ⇒ Object
90 91 92 |
# File 'lib/restspec/endpoints/dsl.rb', line 90 def method(method) endpoint.method = method end |
#path(path) ⇒ Object
94 95 96 |
# File 'lib/restspec/endpoints/dsl.rb', line 94 def path(path) endpoint.path = path end |
#schema(name, schema_extensions = {}) ⇒ Object
98 99 100 101 |
# File 'lib/restspec/endpoints/dsl.rb', line 98 def schema(name, schema_extensions = {}) endpoint.schema_name = name endpoint.schema_extensions = schema_extensions end |
#url_param(param, &value_or_type_block) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/restspec/endpoints/dsl.rb', line 107 def url_param(param, &value_or_type_block) endpoint.add_url_param_block(param) do value_or_type_context = ValueOrTypeContext.new value_or_type = value_or_type_context.instance_eval(&value_or_type_block) if value_or_type.is_a?(Restspec::Schema::Types::BasicType) attribute = if endpoint.schema && endpoint.schema.attributes[param] endpoint.schema.attributes[param] else Restspec::Schema::Attribute.new(param, value_or_type_context.integer) end value_or_type.example_for(attribute) else value_or_type end end end |