Class: JsonApiClient::Schema
- Inherits:
-
Object
- Object
- JsonApiClient::Schema
- Defined in:
- lib/json_api_client/schema.rb
Defined Under Namespace
Classes: Property
Instance Method Summary collapse
-
#add(name, options) ⇒ void
Add a property to the schema.
- #each_property(&block) ⇒ Object (also: #each)
-
#find(property_name) ⇒ Property?
(also: #[])
Look up a property by name.
-
#initialize ⇒ Schema
constructor
A new instance of Schema.
-
#size ⇒ Fixnum
(also: #length)
How many properties are defined.
Constructor Details
#initialize ⇒ Schema
Returns a new instance of Schema.
33 34 35 |
# File 'lib/json_api_client/schema.rb', line 33 def initialize @properties = {} end |
Instance Method Details
#add(name, options) ⇒ void
This method returns an undefined value.
Add a property to the schema
44 45 46 |
# File 'lib/json_api_client/schema.rb', line 44 def add(name, ) @properties[name.to_sym] = Property.new(name.to_sym, [:type], [:default]) end |
#each_property(&block) ⇒ Object Also known as: each
56 57 58 |
# File 'lib/json_api_client/schema.rb', line 56 def each_property(&block) @properties.values.each(&block) end |
#find(property_name) ⇒ Property? Also known as: []
Look up a property by name
65 66 67 |
# File 'lib/json_api_client/schema.rb', line 65 def find(property_name) @properties[property_name.to_sym] end |
#size ⇒ Fixnum Also known as: length
How many properties are defined
51 52 53 |
# File 'lib/json_api_client/schema.rb', line 51 def size @properties.size end |