Class: SimpleHdGraph::ContextNode

Inherits:
Node
  • Object
show all
Defined in:
lib/simple-hd-graph/context.rb

Constant Summary

Constants inherited from Node

Node::CAMELIZE_SEPARATOR

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#camelize, #initialize, #load, required

Constructor Details

This class inherits a constructor from SimpleHdGraph::Node

Instance Attribute Details

#dependsObject (readonly)

Array



7
8
9
# File 'lib/simple-hd-graph/context.rb', line 7

def depends
  @depends
end

#relationsObject (readonly)

Array



7
8
9
# File 'lib/simple-hd-graph/context.rb', line 7

def relations
  @relations
end

#resourcesObject (readonly)

Array



7
8
9
# File 'lib/simple-hd-graph/context.rb', line 7

def resources
  @resources
end

Instance Method Details

#<<(resource) ⇒ Object

Parameters:



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

#aliasString

Returns:

  • (String)


12
13
14
# File 'lib/simple-hd-graph/context.rb', line 12

def alias
  @content[:id]
end

#idString

Returns:

  • (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_relationObject



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

Parameters:

  • depends (Array)


38
39
40
# File 'lib/simple-hd-graph/context.rb', line 38

def set_depends(depends)
  @depends = depends
end