Class: Dupe::Attribute
- Inherits:
-
Object
- Object
- Dupe::Attribute
- Defined in:
- lib/dupe/attribute.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(name, value = nil, prock = nil) ⇒ Attribute
constructor
A new instance of Attribute.
- #to_hash ⇒ Object
- #value(v = nil) ⇒ Object
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_hash ⇒ Object
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 |