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
109 def forme_parse(obj)
110   h = _forme_parse(obj)
111   
112   params = h.delete(:params)
113   columns = h.delete(:columns)
114   h[:validations] ||= {}
115 
116   values = h[:values] = {}
117   columns.each do |col|
118     values[col.to_sym] = params[col]
119   end
120 
121   h
122 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
126 def forme_set(obj)
127   h = _forme_parse(obj)
128 
129   obj.set_fields(h[:params], h[:columns])
130 
131   if h[:validations]
132     obj.forme_validations.merge!(h[:validations])
133   end
134 
135   if block_given?
136     yield h[:form_version], obj
137   end
138 
139   obj
140 end