Class: BitmaskAttribute::Definition

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute, values = [], &extension) ⇒ Definition

Returns a new instance of Definition.



11
12
13
14
15
# File 'lib/bitmask_attribute.rb', line 11

def initialize(attribute, values=[], &extension)
  @attribute = attribute
  @values = values
  @extension = extension
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



10
11
12
# File 'lib/bitmask_attribute.rb', line 10

def attribute
  @attribute
end

#extensionObject (readonly)

Returns the value of attribute extension.



10
11
12
# File 'lib/bitmask_attribute.rb', line 10

def extension
  @extension
end

#valuesObject (readonly)

Returns the value of attribute values.



10
11
12
# File 'lib/bitmask_attribute.rb', line 10

def values
  @values
end

Instance Method Details

#install_on(model) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/bitmask_attribute.rb', line 17

def install_on(model)
  validate_for model
  generate_bitmasks_on model
  override model
  create_convenience_class_method_on(model)
  create_convenience_instance_methods_on(model)
  create_named_scopes_on(model) if defined?(ActiveRecord::Base) && model.respond_to?(scope_method)
end