Class: SimpleHdGraph::ResourceNode

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

Constant Summary

Constants inherited from Node

Node::CAMELIZE_SEPARATOR

Instance Method Summary collapse

Methods inherited from Node

#camelize, #initialize, #load, required

Constructor Details

This class inherits a constructor from SimpleHdGraph::Node

Instance Method Details

#aliasString

Returns:

  • (String)


17
18
19
# File 'lib/simple-hd-graph/resource.rb', line 17

def alias
  @content.keys.first.to_s.freeze
end

#contentHash

Returns:

  • (Hash)


40
41
42
43
44
# File 'lib/simple-hd-graph/resource.rb', line 40

def content
  @content.values.first.select { |key, value| # rubocop:disable Style/HashExcept
    key != "has"
  }
end

#contextString

Returns:

  • (String)


33
34
35
# File 'lib/simple-hd-graph/resource.rb', line 33

def context
  @context[:id].freeze
end

#hasArray

Returns:

  • (Array)


49
50
51
# File 'lib/simple-hd-graph/resource.rb', line 49

def has
  @content.values.first["has"]
end

#idString

Returns:

  • (String)


24
25
26
27
28
# File 'lib/simple-hd-graph/resource.rb', line 24

def id
  id = camelize(context)
  id[0] = id[0].downcase
  [id, camelize(self.alias)].join("").freeze
end

#load_with_context(context, struct) ⇒ Object

Parameters:

  • context (Object)
  • struct (Hash)


9
10
11
12
# File 'lib/simple-hd-graph/resource.rb', line 9

def load_with_context(context, struct)
  @context = context
  load(struct)
end