Class: Rundock::Attribute::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rundock/attribute/base.rb

Direct Known Subclasses

NodeAttribute

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr = {}) ⇒ Base

Returns a new instance of Base.



4
5
6
# File 'lib/rundock/attribute/base.rb', line 4

def initialize(attr = {})
  attr.each { |k, v| define_attr(k.to_sym, v) }
end

Class Method Details

.attr_accessor(*vars) ⇒ Object



8
9
10
11
12
# File 'lib/rundock/attribute/base.rb', line 8

def self.attr_accessor(*vars)
  @attributes ||= []
  @attributes.concat(vars)
  super(*vars)
end

.listObject



14
15
16
# File 'lib/rundock/attribute/base.rb', line 14

def self.list
  @attributes
end

Instance Method Details

#define_attr(name, val) ⇒ Object



24
25
26
27
# File 'lib/rundock/attribute/base.rb', line 24

def define_attr(name, val)
  self.class.send(:attr_accessor, name)
  self.send("#{name}=", val)
end

#listObject



18
19
20
21
22
# File 'lib/rundock/attribute/base.rb', line 18

def list
  self.class.list.each_with_object({}) do |a, result|
    result[a] = self.send(a)
  end
end