Sha256: 5f38ef7c00b3c2a22284b0f4c9afafc62b1b3ccad63c440e712d400085e466a6

Contents?: true

Size: 381 Bytes

Versions: 4

Compression:

Stored size: 381 Bytes

Contents

require 'hashie/dash'

module Polytrix
  class Validations < Set
    def to_hash
      map do |v|
        v.to_hash
      end
    end

    def to_yaml
      to_hash.to_yaml
    end

    # Hashie Coercion - automatically treat all values as Validation
    def self.coerce(obj)
      data = obj.map do |value|
        Validation.new(value)
      end
      new data
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
polytrix-0.1.2 lib/polytrix/validations.rb
polytrix-0.1.1 lib/polytrix/validations.rb
polytrix-0.1.0 lib/polytrix/validations.rb
polytrix-0.1.0.pre lib/polytrix/validations.rb