Class: Aries::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/aries/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, schema, parent = nil) ⇒ Resource

Returns a new instance of Resource.

Parameters:

  • name (String)

    of schema

  • json (JsonSchema::Schema)

    schema object



10
11
12
13
14
# File 'lib/aries/resource.rb', line 10

def initialize name, schema, parent = nil
  @name   = name
  @schema = schema
  @parent = parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



5
6
7
# File 'lib/aries/resource.rb', line 5

def parent
  @parent
end

Instance Method Details

Returns links owned by resource.

Returns:



22
23
24
25
26
# File 'lib/aries/resource.rb', line 22

def links
  @links ||= @schema.links.map do |link|
    Link.new(link, self)
  end
end

#nameObject

Returns String name of resource.

Returns:

  • String name of resource



17
18
19
# File 'lib/aries/resource.rb', line 17

def name
  @name.split('-').join("_")
end

#root_schemaAries::Schema

Returns Root schema of resource.

Returns:



29
30
31
# File 'lib/aries/resource.rb', line 29

def root_schema
  @parent.respond_to?(:parent) ? @parent.root_schema : @parent
end