module Roda::RodaPlugins::FormeSet::InstanceMethods

  1. lib/roda/plugins/forme_set.rb

Methods

Public Instance

  1. forme_parse
  2. forme_set

Public Instance methods

forme_parse(obj)

Return hash based on submitted parameters, with :values key being submitted values for the object, and :validations key being a hash of validation metadata for the object.

[show source]
   # File lib/roda/plugins/forme_set.rb
41 def forme_parse(obj)
42   h = _forme_parse(obj)
43   
44   params = h.delete(:params)
45   columns = h.delete(:columns)
46   h[:validations] ||= {}
47 
48   values = h[:values] = {}
49   columns.each do |col|
50     values[col.to_sym] = params[col]
51   end
52 
53   h
54 end
forme_set(obj)

Set fields on the object based on submitted parameters, as well as validations for associated object values.

[show source]
   # File lib/roda/plugins/forme_set.rb
58 def forme_set(obj)
59   h = _forme_parse(obj)
60 
61   obj.set_fields(h[:params], h[:columns])
62 
63   if h[:validations]
64     obj.forme_validations.merge!(h[:validations])
65   end
66 
67   if block_given?
68     yield h[:form_version], obj
69   end
70 
71   obj
72 end