Class: SmoothOperator::Rails

Inherits:
Base show all
Includes:
ActiveModel::Conversion, ActiveModel::Validations, ActiveModel::Validations::Callbacks
Defined in:
lib/smooth_operator.rb

Constant Summary

Constants included from HttpMethods

HttpMethods::HTTP_VERBS

Instance Attribute Summary

Attributes included from Persistence

#last_remote_call

Attributes included from AttributeAssignment

#_meta_data, #_options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

smooth_operator?

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

#find

Methods included from Translation

#human_attribute_name

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, options = {})
  SmoothOperator::Translation::HelperMethods.translate(
    "attributes.#{model_name.i18n_key}.#{attribute_key_name}",
    options
  )
end

.model_nameObject



76
77
78
# File 'lib/smooth_operator.rb', line 76

def self.model_name
  smooth_model_name
end

Instance Method Details

#after_saveObject



74
# File 'lib/smooth_operator.rb', line 74

def after_save; end

#before_saveObject



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 = {}, options = {})
  return false unless before_save

  clear_induced_errors

  save_result = valid? ? super : false

  after_save if valid? && save_result

  save_result
end