Module: StixSchemaSpy::HasChildren

Included in:
ComplexType, Schema
Defined in:
lib/stix_schema_spy/models/has_children.rb

Instance Method Summary collapse

Instance Method Details

#attributes(all = true) ⇒ Object



30
31
32
33
# File 'lib/stix_schema_spy/models/has_children.rb', line 30

def attributes(all = true)
  load!
  (@attributes.values + (all && parent_type ? parent_type.attributes : []))
end

#elements(all = true) ⇒ Object



25
26
27
28
# File 'lib/stix_schema_spy/models/has_children.rb', line 25

def elements(all = true)
  load!
  (@elements.values + (all && parent_type ? parent_type.elements : []))
end

#fieldsObject



40
41
42
43
# File 'lib/stix_schema_spy/models/has_children.rb', line 40

def fields
  load!
  (parent_type ? parent_type.fields : []) + own_fields
end

#find_attribute(name, all = true) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/stix_schema_spy/models/has_children.rb', line 14

def find_attribute(name, all = true)
  load!
  if @attributes[name]
    @attributes[name]
  elsif parent_type && all && parent_type.respond_to?(:find_attribute)
    parent_type.find_attribute(name)
  else
    nil
  end
end

#find_element(name, all = true) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/stix_schema_spy/models/has_children.rb', line 3

def find_element(name, all = true)
  load!
  if @elements[name]
    @elements[name]
  elsif parent_type && all && parent_type.respond_to?(:find_element)
    parent_type.find_element(name)
  else
    nil
  end
end

#own_fieldsObject



35
36
37
38
# File 'lib/stix_schema_spy/models/has_children.rb', line 35

def own_fields
  load!
  attributes(false) + elements(false) + @special_fields
end