Class: Restspec::Endpoints::EndpointDSL::ExampleOrValue

Inherits:
Object
  • Object
show all
Defined in:
lib/restspec/endpoints/dsl.rb

Overview

A special class to get a type example or a simple value from a block.

If the block returns a type, the result should be one example of that type.

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, attribute_name, callable) ⇒ ExampleOrValue

Returns a new instance of ExampleOrValue.



333
334
335
336
337
# File 'lib/restspec/endpoints/dsl.rb', line 333

def initialize(endpoint, attribute_name, callable)
  self.attribute_name = attribute_name
  self.endpoint = endpoint
  self.callable = callable
end

Instance Method Details

#valueObject



339
340
341
342
343
344
345
# File 'lib/restspec/endpoints/dsl.rb', line 339

def value
  if example?
    raw_value.example_for(get_attribute)
  else
    raw_value
  end
end