Class: Penchant::CustomProperty

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

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ CustomProperty

Returns a new instance of CustomProperty.



3
4
5
# File 'lib/penchant/custom_property.rb', line 3

def initialize(value)
  @value = value
end

Instance Method Details

#process(values) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/penchant/custom_property.rb', line 7

def process(values)
  if @value.respond_to?(:call)
    @value.call(*values).to_a
  else
    @value.collect do |k, v|
      v = v.dup.gsub(%r{\$(\d+)}) { |m| values[m.to_i - 1 ] }

      [ k, v ]
    end
  end
end