Class: Philosophal::Properties::Schema
- Inherits:
-
Object
- Object
- Philosophal::Properties::Schema
- Includes:
- Enumerable
- Defined in:
- lib/philosophal/properties/schema.rb
Instance Attribute Summary collapse
-
#properties_index ⇒ Object
readonly
Returns the value of attribute properties_index.
Instance Method Summary collapse
- #<<(value) ⇒ Object
- #[](key) ⇒ Object
- #immutables ⇒ Object
-
#initialize(properties_index: {}) ⇒ Schema
constructor
A new instance of Schema.
- #json_names_h ⇒ Object
- #keys ⇒ Object
- #mutables ⇒ Object
Constructor Details
#initialize(properties_index: {}) ⇒ Schema
Returns a new instance of Schema.
8 9 10 11 |
# File 'lib/philosophal/properties/schema.rb', line 8 def initialize(properties_index: {}) @properties_index = properties_index @mutex = Mutex.new end |
Instance Attribute Details
#properties_index ⇒ Object (readonly)
Returns the value of attribute properties_index.
13 14 15 |
# File 'lib/philosophal/properties/schema.rb', line 13 def properties_index @properties_index end |
Instance Method Details
#<<(value) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/philosophal/properties/schema.rb', line 23 def <<(value) @mutex.synchronize do @properties_index[value.name] = value end self end |
#[](key) ⇒ Object
15 16 17 |
# File 'lib/philosophal/properties/schema.rb', line 15 def [](key) @properties_index[key] end |
#immutables ⇒ Object
31 32 33 34 35 |
# File 'lib/philosophal/properties/schema.rb', line 31 def immutables return @immutables if defined?(@immutables) @immutables = @properties_index.select { |_, v| v.immutable } end |
#json_names_h ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/philosophal/properties/schema.rb', line 43 def json_names_h return @json_names_h if defined?(@json_names_h) @json_names_h = @properties_index.to_h do |key, property| [property.json_name, key] end end |
#keys ⇒ Object
19 20 21 |
# File 'lib/philosophal/properties/schema.rb', line 19 def keys @properties_index.keys end |
#mutables ⇒ Object
37 38 39 40 41 |
# File 'lib/philosophal/properties/schema.rb', line 37 def mutables return @mutables if defined?(@mutables) @mutables = @properties_index.reject { |_, v| v.immutable } end |