Class: SimpleHdGraph::ContextNode
- Defined in:
- lib/simple-hd-graph/context.rb
Constant Summary
Constants inherited from Node
Instance Attribute Summary collapse
-
#depends ⇒ Object
readonly
Array.
-
#relations ⇒ Object
readonly
Array.
-
#resources ⇒ Object
readonly
Array.
Instance Method Summary collapse
- #<<(resource) ⇒ Object
- #alias ⇒ String
- #id ⇒ String
- #refill_relation ⇒ Object
- #set_depends(depends) ⇒ Object
Methods inherited from Node
#camelize, #initialize, #load, required
Constructor Details
This class inherits a constructor from SimpleHdGraph::Node
Instance Attribute Details
#depends ⇒ Object (readonly)
Array
7 8 9 |
# File 'lib/simple-hd-graph/context.rb', line 7 def depends @depends end |
#relations ⇒ Object (readonly)
Array
7 8 9 |
# File 'lib/simple-hd-graph/context.rb', line 7 def relations @relations end |
#resources ⇒ Object (readonly)
Array
7 8 9 |
# File 'lib/simple-hd-graph/context.rb', line 7 def resources @resources end |
Instance Method Details
#<<(resource) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/simple-hd-graph/context.rb', line 28 def <<(resource) @resources ||= [] @resource_dict ||= {} @resources << resource @resource_dict[resource.alias] = resource.id end |
#alias ⇒ String
12 13 14 |
# File 'lib/simple-hd-graph/context.rb', line 12 def alias @content[:id] end |
#id ⇒ String
19 20 21 22 23 |
# File 'lib/simple-hd-graph/context.rb', line 19 def id id = camelize(self.alias) id[0] = id[0].downcase id end |
#refill_relation ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/simple-hd-graph/context.rb', line 42 def refill_relation @resource ||= [] @relations ||= [] @resources.each { |resource| dependencies = resource.has if dependencies.respond_to? :each dependencies.each { |dependency| @relations << {resource.id => @resource_dict[dependency]} } end } end |
#set_depends(depends) ⇒ Object
38 39 40 |
# File 'lib/simple-hd-graph/context.rb', line 38 def set_depends(depends) @depends = depends end |