Class: Services::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/services/entity.rb

Overview

entity base class. member,service,endpoint are all “services::entity”

Direct Known Subclasses

Endpoint, Member

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, args = {}) ⇒ Entity

Returns a new instance of Entity.



12
13
14
15
# File 'lib/services/entity.rb', line 12

def initialize(name, args = {})
  @name = name
  validate
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/services/entity.rb', line 11

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/services/entity.rb', line 11

def path
  @path
end

Instance Method Details

#loadObject



22
23
24
# File 'lib/services/entity.rb', line 22

def load
  _load
end

#storeObject Also known as: save



17
18
19
# File 'lib/services/entity.rb', line 17

def store
  _store
end

#to_hashObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/services/entity.rb', line 26

def to_hash
  vars = {}
  instance_variables.each do |name|
    key = name[1..-1].to_s
    # don't store "path"
    next if key == 'path'
    vars[key] =  instance_variable_get(name).to_s
  end
  vars
end