Class: Iqvoc::Origin
- Inherits:
-
Object
- Object
- Iqvoc::Origin
- Defined in:
- lib/iqvoc/origin.rb
Defined Under Namespace
Modules: Filters
Instance Attribute Summary collapse
-
#filters ⇒ Object
Returns the value of attribute filters.
-
#initial_value ⇒ Object
Returns the value of attribute initial_value.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value) ⇒ Origin
constructor
A new instance of Origin.
- #inspect ⇒ Object
- #method_missing(meth, *args) ⇒ Object
- #run_filters! ⇒ Object
- #to_s ⇒ Object
- #touched? ⇒ Boolean
Constructor Details
#initialize(value) ⇒ Origin
Returns a new instance of Origin.
113 114 115 116 |
# File 'lib/iqvoc/origin.rb', line 113 def initialize(value) self.initial_value = value.to_s self.value = initial_value end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/iqvoc/origin.rb', line 128 def method_missing(meth, *args) if Filters.registered.keys.include?(meth.to_sym) Filters.registered[meth.to_sym].new.call(self, value) else super end end |
Instance Attribute Details
#filters ⇒ Object
Returns the value of attribute filters.
111 112 113 |
# File 'lib/iqvoc/origin.rb', line 111 def filters @filters end |
#initial_value ⇒ Object
Returns the value of attribute initial_value.
111 112 113 |
# File 'lib/iqvoc/origin.rb', line 111 def initial_value @initial_value end |
#value ⇒ Object
Returns the value of attribute value.
111 112 113 |
# File 'lib/iqvoc/origin.rb', line 111 def value @value end |
Instance Method Details
#inspect ⇒ Object
142 143 144 |
# File 'lib/iqvoc/origin.rb', line 142 def inspect "#<Iqvoc::Origin:0x%08x>" % object_id end |
#run_filters! ⇒ Object
122 123 124 125 126 |
# File 'lib/iqvoc/origin.rb', line 122 def run_filters! Filters.registered.each do |key, filter_class| filter_class.new.call(self, value) end end |
#to_s ⇒ Object
136 137 138 139 140 |
# File 'lib/iqvoc/origin.rb', line 136 def to_s return value if touched? run_filters! value end |
#touched? ⇒ Boolean
118 119 120 |
# File 'lib/iqvoc/origin.rb', line 118 def touched? value != initial_value end |