Class: Dendrite::Generators::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dendrite/generators/base.rb

Direct Known Subclasses

Nerve, Synapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph:, service_names:) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
# File 'lib/dendrite/generators/base.rb', line 6

def initialize(graph:, service_names:)
  @graph = graph
  @services = graph.services
                   .select { |service_name, service| service_names.include?(service_name) }
                   .collect { |_, service| service }
end

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



4
5
6
# File 'lib/dendrite/generators/base.rb', line 4

def graph
  @graph
end

#servicesObject (readonly)

Returns the value of attribute services.



4
5
6
# File 'lib/dendrite/generators/base.rb', line 4

def services
  @services
end

Instance Method Details

#to_hObject

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/dendrite/generators/base.rb', line 13

def to_h
  raise NotImplementedError
end

#to_jsonObject



21
22
23
# File 'lib/dendrite/generators/base.rb', line 21

def to_json
  self.to_h.to_json
end

#to_yamlObject



17
18
19
# File 'lib/dendrite/generators/base.rb', line 17

def to_yaml
  self.to_h.deep_stringify_keys.to_yaml
end