Sha256: 12cf7276d9d20004b8ab5ea1406dd3e233b343bb2c1d055c0ae065eaaa3f8eea

Contents?: true

Size: 291 Bytes

Versions: 19

Compression:

Stored size: 291 Bytes

Contents

module Vedeu
  module Collection
    extend self

    def coercer(value, model, key)
      return [] if value.nil? || value.empty?

      if value.is_a?(::String)
        [model.new({ key => value })]

      else
        [value].flatten.map { |v| model.new(v) }

      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
vedeu-0.1.7 lib/vedeu/models/attributes/collection.rb
vedeu-0.1.6 lib/vedeu/models/attributes/collection.rb
vedeu-0.1.5 lib/vedeu/models/attributes/collection.rb
vedeu-0.1.4 lib/vedeu/models/attributes/collection.rb
vedeu-0.1.3 lib/vedeu/models/attributes/collection.rb
vedeu-0.1.2 lib/vedeu/models/attributes/collection.rb
vedeu-0.1.1 lib/vedeu/models/attributes/collection.rb
vedeu-0.1.0 lib/vedeu/models/attributes/collection.rb
vedeu-0.0.42 lib/vedeu/models/attributes/collection.rb
vedeu-0.0.41 lib/vedeu/models/attributes/collection.rb
vedeu-0.0.40 lib/vedeu/models/attributes/collection.rb
vedeu-0.0.39 lib/vedeu/models/attributes/collection.rb
vedeu-0.0.38 lib/vedeu/models/attributes/collection.rb
vedeu-0.0.37 lib/vedeu/models/attributes/collection.rb
vedeu-0.0.36 lib/vedeu/models/attributes/collection.rb
vedeu-0.0.35 lib/vedeu/models/attributes/collection.rb
vedeu-0.0.34 lib/vedeu/models/attributes/collection.rb
vedeu-0.0.33 lib/vedeu/models/collection.rb
vedeu-0.0.32 lib/vedeu/models/collection.rb