Class: Paradocs::Policies::Split
- Inherits:
-
BasePolicy
- Object
- BasePolicy
- Paradocs::Policies::Split
- Defined in:
- lib/paradocs/policies.rb
Instance Attribute Summary
Attributes inherited from BasePolicy
Instance Method Summary collapse
- #coerce(v) ⇒ Object
-
#initialize(delimiter = /\s*,\s*/) ⇒ Split
constructor
A new instance of Split.
Methods inherited from BasePolicy
build, coerce, eligible, #eligible?, message, #message, meta_data, #meta_data, policy_name, #policy_name, policy_name=, #valid?, validate
Constructor Details
#initialize(delimiter = /\s*,\s*/) ⇒ Split
Returns a new instance of Split.
23 24 25 |
# File 'lib/paradocs/policies.rb', line 23 def initialize(delimiter=/\s*,\s*/) @delimiter = delimiter end |
Instance Method Details
#coerce(v) ⇒ Object
27 28 29 |
# File 'lib/paradocs/policies.rb', line 27 def coerce(v, *) v.kind_of?(Array) ? v : v.to_s.split(@delimiter) end |