Class: Brujula::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/brujula/object.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:, parent: nil, name:) ⇒ Object

Returns a new instance of Object.



20
21
22
23
24
25
26
# File 'lib/brujula/object.rb', line 20

def initialize(data:, parent: nil, name:)
  @name = name
  define_singleton_method(:raw_data) { data }
  define_singleton_method(:parent)   { parent }

  Brujula::ObjectParser.call(definition: self, data: data, parent: parent)
end

Class Attribute Details

.blockObject (readonly)

Returns the value of attribute block.



6
7
8
# File 'lib/brujula/object.rb', line 6

def block
  @block
end

.scheme(options = {}, &block) ⇒ Object (readonly)

TODO



8
9
10
# File 'lib/brujula/object.rb', line 8

def scheme
  @scheme
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/brujula/object.rb', line 3

def name
  @name
end

Instance Method Details

#expandObject

TODO



28
29
30
# File 'lib/brujula/object.rb', line 28

def expand # TODO
  @representation || self
end

#rootObject



32
33
34
35
36
37
38
# File 'lib/brujula/object.rb', line 32

def root
  object = self
  until object.is_a? Brujula::Raml::V1_0::Root
    object = object.parent
  end
  object
end