Sha256: 0229144d74238fc5196b940f3a408d3b475943f69a863a41a0755c06180cac66
Contents?: true
Size: 1.68 KB
Versions: 6
Compression:
Stored size: 1.68 KB
Contents
# frozen_string_literal: true <% module_namespacing do -%> class <%= form_name %> include Formify::Form attr_accessor :<%= attributes_with_delegates.first %><%= ',' if attributes_with_delegates.count > 1 %> <% attributes_with_delegates[1..-1].each_with_index do |attr, i| -%> :<%= attr %><%= ',' unless attributes_with_delegates.count - 2 == i %> <% end -%> <% delegated_attributes.each do |to_attr, delegates| -%> delegate_accessor :<%= delegates.first %>, <% delegates[1..-1].each_with_index do |attr, i| -%> :<%= attr %>, <% end -%> to: :<%= to_attr %> <% end -%> # before_validation :before_validation_do_something validates_presence_of :<%= all_attributes.first %><%= ',' if all_attributes.count > 1 %> <% all_attributes[1..-1].each_with_index do |attr, i| -%> :<%= attr %><%= ',' unless all_attributes.count - 2 == i %> <% end -%> # validate :validate_something initialize_with :<%= attributes_with_delegates.join(', :') %> do |attributes| <% if create? -%> self.<%= collection.singularize %> ||= <%= inferred_model_name %>.new <% end -%> puts attributes end def save raise NotImplementedError with_advisory_lock_transaction(:foo) do validate_or_fail .and_then { <%= name.split('/').reverse[0..1].map(&:singularize).join('_').underscore %> } .and_then { success(<%= return_attribute %>) } end end private def <%= name.split('/').reverse[0..1].map(&:singularize).join('_').underscore %> raise NotImplementedError success(<%= return_attribute %>) end # def before_validation_do_something # end # def validate_something # end end <% end -%>
Version data entries
6 entries across 6 versions & 1 rubygems