Class: WebMock::Resources::SchemaBuilder
- Inherits:
-
Object
- Object
- WebMock::Resources::SchemaBuilder
- Defined in:
- lib/webmock-resources/schema_builder.rb
Instance Method Summary collapse
- #attribute(name, value = nil, &block) ⇒ Object
-
#initialize(resource_type) ⇒ SchemaBuilder
constructor
A new instance of SchemaBuilder.
- #object(clazz) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(resource_type) ⇒ SchemaBuilder
Returns a new instance of SchemaBuilder.
4 5 6 7 8 9 10 |
# File 'lib/webmock-resources/schema_builder.rb', line 4 def initialize resource_type @schema = Schema.new resource_type @schema.object = begin resource_class = resource_type.to_s.classify resource_class.constantize if Object.const_defined? resource_class end end |
Instance Method Details
#attribute(name, value = nil, &block) ⇒ Object
12 13 14 |
# File 'lib/webmock-resources/schema_builder.rb', line 12 def attribute name, value = nil, &block @schema.fields[name] = block_given? ? block : value end |
#object(clazz) ⇒ Object
16 17 18 |
# File 'lib/webmock-resources/schema_builder.rb', line 16 def object clazz @schema.object = clazz end |
#to_hash ⇒ Object
20 21 22 |
# File 'lib/webmock-resources/schema_builder.rb', line 20 def to_hash @schema end |