Module: BitmaskAttribute::Attribute

Defined in:
lib/bitmask_attribute/attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/bitmask_attribute/attribute.rb', line 3

def attributes
  @attributes
end

Instance Method Details

#initialize(attrs = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/bitmask_attribute/attribute.rb', line 5

def initialize(attrs = {})
  @attributes = {}
  attrs.each do |k,v|
    sym = :"#{k}="
    if respond_to? sym
      send sym, v
    else
      write_attribute(k, v)
    end
  end
end

#read_attribute(attr_name) ⇒ Object



17
18
19
# File 'lib/bitmask_attribute/attribute.rb', line 17

def read_attribute(attr_name)
  @attributes[attr_name.to_s]
end

#write_attribute(attr_name, value) ⇒ Object



21
22
23
# File 'lib/bitmask_attribute/attribute.rb', line 21

def write_attribute(attr_name, value)
  @attributes[attr_name.to_s] = value
end