Sha256: e76834c174f29b505dbf61f2ab7d4d44c38338948840f7b33ea6dd3acafe52e6
Contents?: true
Size: 924 Bytes
Versions: 4
Compression:
Stored size: 924 Bytes
Contents
module Vedeu # Provides means to convert attributes into the correct model. # # @api private module Coercions include Vedeu::Common # Produces new objects of the correct class from attributes hashes, # ignores objects that have already been coerced. # # @param values [Array|Hash] # @return [Array] 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 # Whenever this module {Vedeu::Coercions} is included in another class or # module, make its methods into class methods, so they may be called # directly. # # @param receiver [Class] The class in which this module is included. # @return [] def self.included(receiver) receiver.extend(self) end end # Coercions end # Vedeu
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.2.12 | lib/vedeu/support/coercions.rb |
vedeu-0.2.11 | lib/vedeu/support/coercions.rb |
vedeu-0.2.10 | lib/vedeu/support/coercions.rb |
vedeu-0.2.9 | lib/vedeu/support/coercions.rb |