Class: Polytrix::Validations

Inherits:
Set
  • Object
show all
Defined in:
lib/polytrix/validations.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.coerce(obj) ⇒ Object

Hashie Coercion - automatically treat all values as Validation



16
17
18
19
20
21
# File 'lib/polytrix/validations.rb', line 16

def self.coerce(obj)
  data = obj.map do |value|
    Validation.new(value)
  end
  new data
end

Instance Method Details

#to_hashObject



5
6
7
8
9
# File 'lib/polytrix/validations.rb', line 5

def to_hash
  map do |v|
    v.to_hash
  end
end

#to_yamlObject



11
12
13
# File 'lib/polytrix/validations.rb', line 11

def to_yaml
  to_hash.to_yaml
end