Class: Odin::Types::OdinObject
Instance Attribute Summary collapse
Attributes inherited from OdinValue
#directives, #modifiers
Instance Method Summary
collapse
Methods inherited from OdinValue
#array?, #binary?, #boolean?, #confidential?, #currency?, #date?, #deprecated?, #duration?, #integer?, #null?, #number?, #numeric?, #object?, #percent?, #reference?, #required?, #string?, #temporal?, #time?, #timestamp?, #verb?
Constructor Details
#initialize(entries: {}, **kwargs) ⇒ OdinObject
Returns a new instance of OdinObject.
579
580
581
582
583
|
# File 'lib/odin/types/values.rb', line 579
def initialize(entries: {}, **kwargs)
super(**kwargs)
@entries = entries.freeze
freeze
end
|
Instance Attribute Details
#entries ⇒ Object
Returns the value of attribute entries.
577
578
579
|
# File 'lib/odin/types/values.rb', line 577
def entries
@entries
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
596
597
598
|
# File 'lib/odin/types/values.rb', line 596
def ==(other)
other.is_a?(OdinObject) && entries == other.entries
end
|
#[](key) ⇒ Object
590
|
# File 'lib/odin/types/values.rb', line 590
def [](key); entries[key]; end
|
#empty? ⇒ Boolean
594
|
# File 'lib/odin/types/values.rb', line 594
def empty?; entries.empty?; end
|
#hash ⇒ Object
601
602
603
|
# File 'lib/odin/types/values.rb', line 601
def hash
[ValueType::OBJECT, entries].hash
end
|
#keys ⇒ Object
592
|
# File 'lib/odin/types/values.rb', line 592
def keys; entries.keys; end
|
#size ⇒ Object
Also known as:
length
587
|
# File 'lib/odin/types/values.rb', line 587
def size; entries.size; end
|
#to_s ⇒ Object
605
606
607
|
# File 'lib/odin/types/values.rb', line 605
def to_s
"{#{entries.size} entries}"
end
|
#type ⇒ Object
585
|
# File 'lib/odin/types/values.rb', line 585
def type; ValueType::OBJECT; end
|
#with_directives(dirs) ⇒ Object
613
614
615
|
# File 'lib/odin/types/values.rb', line 613
def with_directives(dirs)
OdinObject.new(entries: entries, modifiers: modifiers, directives: dirs)
end
|
#with_modifiers(mods) ⇒ Object
609
610
611
|
# File 'lib/odin/types/values.rb', line 609
def with_modifiers(mods)
OdinObject.new(entries: entries, modifiers: mods, directives: directives)
end
|