Class: Ordinary::Normalizer
- Inherits:
-
Object
- Object
- Ordinary::Normalizer
- Defined in:
- lib/ordinary/normalizer.rb
Instance Method Summary collapse
-
#coming_under?(model) ⇒ Boolean
Determine if a model coming under a target of the normalizer.
-
#initialize(options = {}, &process) ⇒ Normalizer
constructor
A new instance of Normalizer.
-
#normalize(value) ⇒ Object
Normalize a value by the normalizer.
-
#run_at?(context) ⇒ Boolean
Determine if.
Constructor Details
#initialize(options = {}, &process) ⇒ Normalizer
Returns a new instance of Normalizer.
4 5 6 7 8 |
# File 'lib/ordinary/normalizer.rb', line 4 def initialize( = {}, &process) @determine = extract_determiner() @context = [:on] @process = process end |
Instance Method Details
#coming_under?(model) ⇒ Boolean
Determine if a model coming under a target of the normalizer.
23 24 25 |
# File 'lib/ordinary/normalizer.rb', line 23 def coming_under?(model) @determine.nil? or !!@determine.call(model) end |
#normalize(value) ⇒ Object
Normalize a value by the normalizer.
14 15 16 |
# File 'lib/ordinary/normalizer.rb', line 14 def normalize(value) @process.call(value) end |
#run_at?(context) ⇒ Boolean
Determine if
31 32 33 |
# File 'lib/ordinary/normalizer.rb', line 31 def run_at?(context) @context.nil? or (@context == context) end |