Class: Aries::Resource
- Inherits:
-
Object
- Object
- Aries::Resource
- Defined in:
- lib/aries/resource.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(name, schema, parent = nil) ⇒ Resource
constructor
A new instance of Resource.
-
#links ⇒ Array<Aries::Link>
Links owned by resource.
-
#name ⇒ Object
String name of resource.
-
#root_schema ⇒ Aries::Schema
Root schema of resource.
Constructor Details
#initialize(name, schema, parent = nil) ⇒ Resource
Returns a new instance of Resource.
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
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
5 6 7 |
# File 'lib/aries/resource.rb', line 5 def parent @parent end |
Instance Method Details
#links ⇒ Array<Aries::Link>
Returns links owned by resource.
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 |
#name ⇒ Object
Returns String name of resource.
17 18 19 |
# File 'lib/aries/resource.rb', line 17 def name @name.split('-').join("_") end |
#root_schema ⇒ Aries::Schema
Returns Root schema of resource.
29 30 31 |
# File 'lib/aries/resource.rb', line 29 def root_schema @parent.respond_to?(:parent) ? @parent.root_schema : @parent end |