Module: Juvet::Attributable

Included in:
Bot
Defined in:
lib/juvet/attributable.rb

Instance Method Summary collapse

Instance Method Details

#attribute!(attributes) ⇒ Object



7
8
9
10
# File 'lib/juvet/attributable.rb', line 7

def attribute!(attributes)
  (@_attributes ||= []).concat attributes.keys
  attributes.keys.each { |name| define_attribute! name }
end

#attributesObject



12
13
14
15
16
17
18
19
20
# File 'lib/juvet/attributable.rb', line 12

def attributes
  attributes = {}
  @_attributes.each do |attribute|
    if self.respond_to? attribute
      attributes[attribute] = self.send(attribute)
    end
  end
  attributes
end

#initialize!(attributes) ⇒ Object



3
4
5
# File 'lib/juvet/attributable.rb', line 3

def initialize!(attributes)
  attributes.each { |name, value| set_variable! name, value }
end