Class: Philosophal::Properties::Schema

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/philosophal/properties/schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#immutablesObject



31
32
33
# File 'lib/philosophal/properties/schema.rb', line 31

def immutables
  @properties_index.select { |_, v| v.immutable }
end

#keysObject



19
20
21
# File 'lib/philosophal/properties/schema.rb', line 19

def keys
  @properties_index.keys
end

#mutablesObject



35
36
37
# File 'lib/philosophal/properties/schema.rb', line 35

def mutables
  @properties_index.reject { |_, v| v.immutable }
end