Module: Vedeu::Coercions Private
- Includes:
- Common
- Defined in:
- lib/vedeu/models/attributes/coercions.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Provides means to convert attributes into the correct model.
Class Method Summary collapse
-
.included(receiver) ⇒ Object
private
Whenever this module Coercions is included in another class or module, make its methods into class methods, so they may be called directly.
Instance Method Summary collapse
-
#coercer(values) ⇒ Array
private
Produces new objects of the correct class from attributes hashes, ignores objects that have already been coerced.
Methods included from Common
Class Method Details
.included(receiver) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Whenever this module Vedeu::Coercions is included in another class or module, make its methods into class methods, so they may be called directly.
32 33 34 |
# File 'lib/vedeu/models/attributes/coercions.rb', line 32 def self.included(receiver) receiver.extend(self) end |
Instance Method Details
#coercer(values) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Produces new objects of the correct class from attributes hashes, ignores objects that have already been coerced.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vedeu/models/attributes/coercions.rb', line 15 def coercer(values) return [] unless defined_value?(values) [values].flatten.map do |value| if value.is_a?(self) value else self.new(value) end end end |