Class: Attribool::ReaderName
- Inherits:
-
Object
- Object
- Attribool::ReaderName
- Defined in:
- lib/attribool/reader_name.rb
Overview
Abstraction of a reader’s method name.
Instance Method Summary collapse
-
#initialize(attribute, name) ⇒ ReaderName
constructor
Instantiate new instance of ReaderName.
-
#to_s ⇒ String
Convert instance to a string.
Constructor Details
#initialize(attribute, name) ⇒ ReaderName
Instantiate new instance of ReaderName.
13 14 15 16 |
# File 'lib/attribool/reader_name.rb', line 13 def initialize(attribute, name) @attribute = attribute @name = name end |
Instance Method Details
#to_s ⇒ String
Convert instance to a string.
22 23 24 25 26 27 28 |
# File 'lib/attribool/reader_name.rb', line 22 def to_s case @name when Proc then @name.call(@attribute) when nil then "#{@attribute}?" else @name.to_s end end |