Class: Charisma::Curator::Curation
- Inherits:
-
Delegator
- Object
- Delegator
- Charisma::Curator::Curation
- Extended by:
- Forwardable
- Defined in:
- lib/charisma/curator/curation.rb
Overview
A wrapper around computed characteristic values that intervenes when the value is asked to present itself.
Implements the Delegator pattern, with uncaught methods delegated to the characteristic’s computed value. (Undocumented below is that #to_s
is specifically delegated to #render
.)
Instance Attribute Summary collapse
-
#characteristic ⇒ Charisma::Characteristic
readonly
The characteristic, as defined in the class’s characterization.
-
#value ⇒ Object
The computed value of the characteristic.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#__getobj__ ⇒ Object
Delegator method.
-
#__setobj__(obj) ⇒ Object
Delegator method.
-
#initialize(value, characteristic = nil) ⇒ Curation
constructor
Create new Curation wrapper.
-
#inspect ⇒ Object
An inspection method for more readable IRB sessions and logs.
Constructor Details
#initialize(value, characteristic = nil) ⇒ Curation
Create new Curation wrapper.
This is typically done by the instance’s Charisma::Curator
23 24 25 26 27 |
# File 'lib/charisma/curator/curation.rb', line 23 def initialize(value, characteristic = nil) @characteristic = characteristic establish_units_methods if characteristic && characteristic.measurement self.value = value end |
Instance Attribute Details
#characteristic ⇒ Charisma::Characteristic (readonly)
The characteristic, as defined in the class’s characterization
16 17 18 |
# File 'lib/charisma/curator/curation.rb', line 16 def characteristic @characteristic end |
#value ⇒ Object
The computed value of the characteristic
12 13 14 |
# File 'lib/charisma/curator/curation.rb', line 12 def value @value end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 |
# File 'lib/charisma/curator/curation.rb', line 31 def ==(other) self.value == other.value end |
#__getobj__ ⇒ Object
Delegator method
45 |
# File 'lib/charisma/curator/curation.rb', line 45 def __getobj__; value end |
#__setobj__(obj) ⇒ Object
Delegator method
48 |
# File 'lib/charisma/curator/curation.rb', line 48 def __setobj__(obj); self.value = obj end |
#inspect ⇒ Object
An inspection method for more readable IRB sessions and logs.
36 37 38 39 40 41 42 |
# File 'lib/charisma/curator/curation.rb', line 36 def inspect if characteristic "<Charisma::Curator::Curation for :#{characteristic.name} (use #to_s to render value of #{value.class})>" else "<Charisma::Curator::Curation for undefined characteristic (use #to_s to render value of #{value.class})>" end end |