Class: Paradocs::Policies::Split

Inherits:
BasePolicy show all
Defined in:
lib/paradocs/policies.rb

Instance Attribute Summary

Attributes inherited from BasePolicy

#environment

Instance Method Summary collapse

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