Class: Remont::Attribute

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}, &processor) ⇒ Attribute

Returns a new instance of Attribute.

Parameters:

  • name (Symbol)
  • opts (Hash) (defaults to: {})
  • processor (Proc)
  • [#call] (Hash)

    a customizable set of options



10
11
12
13
# File 'lib/remont/attribute.rb', line 10

def initialize(name, opts = {}, &processor)
  @name = name
  @processor = opts.fetch(:using, processor)
end

Instance Attribute Details

#nameSymbol (readonly)

Returns:

  • (Symbol)


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

def name
  @name
end

Instance Method Details

#process(value, record) ⇒ Object

Parameters:

  • value (Object)
  • record (ActiveRecord::Base)

Returns:

  • (Object)


18
19
20
# File 'lib/remont/attribute.rb', line 18

def process(value, record)
  processor.call(value, record)
end