Class: SmoothOperator::Rails
- Inherits:
-
Base
- Object
- OpenStruct
- Base
- SmoothOperator::Rails
- Includes:
- ActiveModel::Conversion, ActiveModel::Validations, ActiveModel::Validations::Callbacks
- Defined in:
- lib/smooth_operator.rb
Constant Summary
Constants included from HttpMethods
Instance Attribute Summary
Attributes included from Persistence
Attributes included from AttributeAssignment
Class Method Summary collapse
Instance Method Summary collapse
- #after_save ⇒ Object
- #before_save ⇒ Object
- #column_for_attribute(attribute_name) ⇒ Object
- #save(relative_path = nil, data = {}, options = {}) ⇒ Object
Methods inherited from Base
Methods included from Schema
#attribute_type, #internal_structure, #known_attribute?, #schema
Methods included from Associations
#belongs_to, #has_many, #has_one, #rails_serialization, #reflect_on_all_associations, #reflect_on_association, #reflections
Methods included from FinderMethods
Methods included from Translation
Methods included from Persistence
#destroy, #destroyed?, included, #known_attribute?, #marked_for_destruction?, #new_record?, #persisted?, #reload, #save!
Methods included from Operator
#headers, included, #make_the_call, #resource_path
Methods included from Options
#config_options, #get_option, #smooth_operator_options
Methods included from ResourceName
#custom_model_name, #model_name, #resource_name, #resources_name
Methods included from AttributeAssignment
#assign_attributes, #initialize
Methods included from Serialization
#attributes, #read_attribute_for_serialization, #serializable_hash, #to_hash, #to_json
Methods included from InternalData
#internal_data, #internal_data_get, #internal_data_push, #known_attribute?, #known_attributes
Methods included from Validations
#clear_induced_errors, included, #induce_errors, #induced_errors, #invalid?, #valid?
Methods included from Delegation
included, #method_missing, #respond_to?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SmoothOperator::Delegation
Class Method Details
.human_attribute_name(attribute_key_name, options = {}) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/smooth_operator.rb', line 45 def self.human_attribute_name(attribute_key_name, = {}) SmoothOperator::Translation::HelperMethods.translate( "attributes.#{model_name.i18n_key}.#{attribute_key_name}", ) end |
.model_name ⇒ Object
76 77 78 |
# File 'lib/smooth_operator.rb', line 76 def self.model_name smooth_model_name end |
Instance Method Details
#after_save ⇒ Object
74 |
# File 'lib/smooth_operator.rb', line 74 def after_save; end |
#before_save ⇒ Object
70 71 72 |
# File 'lib/smooth_operator.rb', line 70 def before_save true end |
#column_for_attribute(attribute_name) ⇒ Object
52 53 54 55 56 |
# File 'lib/smooth_operator.rb', line 52 def column_for_attribute(attribute_name) type = self.class.attribute_type(attribute_name) ActiveRecord::ConnectionAdapters::Column.new(attribute_name.to_sym, type, type) end |
#save(relative_path = nil, data = {}, options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/smooth_operator.rb', line 58 def save(relative_path = nil, data = {}, = {}) return false unless before_save clear_induced_errors save_result = valid? ? super : false after_save if valid? && save_result save_result end |