Module: Hashme::Attributes

Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/hashme/attributes.rb

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



17
18
19
# File 'lib/hashme/attributes.rb', line 17

def [](key)
  _attributes[key.to_sym]
end

#[]=(key, value) ⇒ Object



13
14
15
# File 'lib/hashme/attributes.rb', line 13

def []=(key, value)
  _attributes[key.to_sym] = value
end

#cloneObject



35
36
37
38
39
# File 'lib/hashme/attributes.rb', line 35

def clone
  new = super
  @_attributes = @_attributes.clone
  new
end

#delete(key) ⇒ Object



25
26
27
# File 'lib/hashme/attributes.rb', line 25

def delete(key)
  _attributes.delete(key.to_sym)
end

#dupObject



29
30
31
32
33
# File 'lib/hashme/attributes.rb', line 29

def dup
  new = super
  @_attributes = @_attributes.dup
  new
end

#has_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/hashme/attributes.rb', line 21

def has_key?(key)
  _attributes.has_key?(key.to_sym)
end

#inspectObject



41
42
43
44
45
46
# File 'lib/hashme/attributes.rb', line 41

def inspect
  string = keys.collect{|key|
    "#{key}: #{self[key].inspect}"
  }.compact.join(", ")
  "#<#{self.class} #{string}>"
end