Class: Acfs::Resource::Attributes::List
- Defined in:
- lib/acfs/resource/attributes/list.rb
Overview
List attribute type. Use it in your model as an attribute type:
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#cast_value(value) ⇒ Fixnum
Cast given object to a list.
Methods inherited from Base
#cast, #default_value, #initialize
Constructor Details
This class inherits a constructor from Acfs::Resource::Attributes::Base
Instance Method Details
#cast_value(value) ⇒ Fixnum
Cast given object to a list.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/acfs/resource/attributes/list.rb', line 22 def cast_value(value) return [] if value.blank? if value.is_a?(::Array) value elsif value.respond_to?(:to_ary) value.to_ary elsif value.respond_to?(:to_a) value.to_a else Array(value) end end |