Class: Eatr::Schema::Field
- Inherits:
-
Object
- Object
- Eatr::Schema::Field
- Defined in:
- lib/eatr/schema.rb
Instance Method Summary collapse
- #children ⇒ Object
-
#initialize(field_attributes) ⇒ Field
constructor
A new instance of Field.
- #node? ⇒ Boolean
- #required? ⇒ Boolean
- #type ⇒ Object
Constructor Details
#initialize(field_attributes) ⇒ Field
Returns a new instance of Field.
4 5 6 |
# File 'lib/eatr/schema.rb', line 4 def initialize(field_attributes) @field_attributes = field_attributes end |
Instance Method Details
#children ⇒ Object
37 38 39 |
# File 'lib/eatr/schema.rb', line 37 def children Array[*@field_attributes['children']].map { |f| Field.new(f) } end |
#node? ⇒ Boolean
29 30 31 |
# File 'lib/eatr/schema.rb', line 29 def node? @field_attributes.has_key?('node') end |
#required? ⇒ Boolean
33 34 35 |
# File 'lib/eatr/schema.rb', line 33 def required? @field_attributes.fetch('required', true) end |
#type ⇒ Object
25 26 27 |
# File 'lib/eatr/schema.rb', line 25 def type @field_attributes['type'].to_s.downcase end |