Class: Gourami::Form
- Inherits:
-
Object
- Object
- Gourami::Form
- Includes:
- Attributes, Coercer, Validations
- Defined in:
- lib/gourami/form.rb
Overview
Base Form for doing actions based on the attributes specified. This class has to be inherited by different forms, each performing a different action. If needed, #validate method can be overridden if necessary.
Constant Summary
Constants included from FormattingConstants
Gourami::FormattingConstants::EMAIL_FORMAT, Gourami::FormattingConstants::HEX_COLOR_FORMAT, Gourami::FormattingConstants::ISRC_FORMAT
Class Method Summary collapse
-
.plugin(name, *args, &block) ⇒ Object
Load and apply a plugin.
Methods included from Coercer
#coerce_array, #coerce_boolean, #coerce_date, #coerce_file, #coerce_float, #coerce_hash, #coerce_integer, #coerce_phone, #coerce_string, #coerce_time, #setter_filter
Methods included from Validations
#any_errors?, #append_error, #append_root_error, #attribute_has_errors?, #clear_and_set_errors, #current_resource, #errors, #get_current_resource_attribute_value, #handle_validation_error, #perform!, #raise_validate_errors, #valid?, #validate, #validate_any, #validate_color_format, #validate_decimal_places, #validate_email_format, #validate_filetype, #validate_format, #validate_inclusion, #validate_inclusion_of_each, #validate_isrc_format, #validate_length, #validate_presence, #validate_range, #validate_uniqueness
Methods included from Attributes
#all_attributes, #attribute_provided?, #attributes, #attributes_hash_from_attributes_options, included, #initialize, #provided_attributes, #provided_attributes_names, #set_attributes, #setter_filter
Class Method Details
.plugin(name, *args, &block) ⇒ Object
Load and apply a plugin. Inspired by the plugin system from the Sequel gem. https://janko.io/the-plugin-system-of-sequel-and-roda/
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/gourami/form.rb', line 97 def self.plugin(name, *args, &block) plugin_module = load_plugin(name) plugin_module.apply(self, *args, &block) if plugin_module.respond_to?(:apply) extend(plugin_module::ClassMethods) if plugin_module.const_defined?(:ClassMethods) include(plugin_module::InstanceMethods) if plugin_module.const_defined?(:InstanceMethods) plugin_module.configure(self, *args, &block) if plugin_module.respond_to?(:configure) end |