Class: Dupe::Attribute

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(name, value = nil, prock = nil) ⇒ Attribute

Returns a new instance of Attribute.



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

def initialize(name, value=nil, prock=nil)
  @name, @value, @prock = name.to_sym, value, prock
end

Instance Method Details

#to_hashObject



12
13
14
# File 'lib/dupe/attribute.rb', line 12

def to_hash
  {@name => value} 
end

#value(v = nil) ⇒ Object



7
8
9
10
# File 'lib/dupe/attribute.rb', line 7

def value(v=nil)
  v = @value.dup if @value and !v
  @prock && v ? @prock.call(v) : v 
end