Class: Ruby::Rego::ObjectValue
Overview
Represents an object value.
Constant Summary collapse
- TYPE_NAME =
"object"
Instance Attribute Summary
Attributes inherited from Value
Instance Method Summary collapse
-
#fetch(key) ⇒ Value
Fetch a value by key.
-
#fetch_reference(key) ⇒ Value
Resolve a reference for an object.
-
#initialize(pairs) ⇒ ObjectValue
constructor
Create an object value.
-
#to_ruby ⇒ Hash<Object, Object>
Convert the object back to Ruby.
Methods inherited from Value
#==, from_ruby, #hash, #object_key, #truthy?, #type_name, #undefined?
Constructor Details
#initialize(pairs) ⇒ ObjectValue
Create an object value.
280 281 282 283 |
# File 'lib/ruby/rego/value.rb', line 280 def initialize(pairs) @values = normalize_pairs(pairs) super(@values) end |
Instance Method Details
#fetch(key) ⇒ Value
Fetch a value by key.
312 313 314 315 316 317 318 |
# File 'lib/ruby/rego/value.rb', line 312 def fetch(key) return @values[key] if @values.key?(key) return fetch_by_symbol_key(key) if key.is_a?(Symbol) UndefinedValue.new end |
#fetch_reference(key) ⇒ Value
Resolve a reference for an object.
324 325 326 |
# File 'lib/ruby/rego/value.rb', line 324 def fetch_reference(key) fetch(key) end |
#to_ruby ⇒ Hash<Object, Object>
Convert the object back to Ruby.
336 337 338 |
# File 'lib/ruby/rego/value.rb', line 336 def to_ruby @values.transform_values(&:to_ruby) end |