Class: Paxmex::Schema
- Inherits:
-
Object
- Object
- Paxmex::Schema
- Defined in:
- lib/paxmex/schema.rb
Defined Under Namespace
Instance Method Summary collapse
-
#initialize(schema_hash) ⇒ Schema
constructor
A new instance of Schema.
- #parent_section?(key) ⇒ Boolean
- #sections ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(schema_hash) ⇒ Schema
Returns a new instance of Schema.
4 5 6 7 |
# File 'lib/paxmex/schema.rb', line 4 def initialize(schema_hash) @schema_hash = schema_hash @parents = [] end |
Instance Method Details
#parent_section?(key) ⇒ Boolean
17 18 19 20 21 22 23 24 25 |
# File 'lib/paxmex/schema.rb', line 17 def parent_section?(key) sections.any? do |s| if s.abstract? s.sections_for_types.any? { |ss| ss.parent_key == key } else s.parent_key == key end end end |
#sections ⇒ Object
9 10 11 |
# File 'lib/paxmex/schema.rb', line 9 def sections @sections ||= @schema_hash.map { |k, v| build_section(k,v) } end |
#to_h ⇒ Object
13 14 15 |
# File 'lib/paxmex/schema.rb', line 13 def to_h @schema_hash end |