Class: Paxmex::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/paxmex/schema.rb

Defined Under Namespace

Classes: Field, Section

Instance Method Summary collapse

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

Returns:

  • (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

#sectionsObject



9
10
11
# File 'lib/paxmex/schema.rb', line 9

def sections
  @sections ||= @schema_hash.map { |k, v| build_section(k,v) }
end

#to_hObject



13
14
15
# File 'lib/paxmex/schema.rb', line 13

def to_h
  @schema_hash
end