Class: Operations::Form::Base

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Includes:
InstanceMethods
Defined in:
lib/operations/form/base.rb

Overview

This class implements Rails form object compatibility layer It is possible to configure form object attributes automatically basing on Dry Schema user Builder

Examples:


class AuthorForm < Operations::Form::Base
  attribute :name
end

class PostForm < Operations::Form::Base
  attribute :title
  attribute :tags, collection: true
  attribute :author, form: AuthorForm
end

PostForm.new({ tags: ["foobar"], author: { name: "Batman" } })
# => #<PostForm attributes={:title=>nil, :tags=>["foobar"], :author=>#<AuthorForm attributes={:name=>"Batman"}>}>

See Also:

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Constant Summary collapse

BUILD_ASSOCIATION_PREFIX =
"build_"
NESTED_ATTRIBUTES_SUFFIX =
"_attributes="

Method Summary

Methods included from ClassMethods

attribute, extended, human_attribute_name, model_name, reflect_on_association, validators_on

Methods included from InstanceMethods

#_destroy, #assigned_attributes, #attributes, #errors, #has_attribute?, #localized_attr_name_for, #method_missing, #model_name, #new_record?, #persisted?, #read_attribute, #respond_to_missing?, #to_hash, #to_key, #type_for_attribute, #valid?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Operations::Form::Base::InstanceMethods