Class: MotionPrime::Model

Inherits:
NSFNanoObject
  • Object
show all
Includes:
HasAuthorization, HasNormalizer, ModelAssociationMixin, ModelBaseMixin, ModelDirtyMixin, ModelFinderMixin, ModelSyncMixin, ModelTimestampsMixin
Defined in:
motion-prime/models/model.rb

Instance Method Summary collapse

Methods included from ModelTimestampsMixin

included, #save!, #trigger_timestamp

Methods included from ModelDirtyMixin

#changed_attributes, #has_changed?, included, #reload, #reset_changed_attributes, #save!, #track_changed_attributes

Methods included from ModelSyncMixin

#association_sync_url, #associations, #associations_to_fetch, #attributes_to_post_data, #destroy, #fetch, #fetch!, #fetch_association, #fetch_association?, #fetch_association_with_attributes, #fetch_associations, #fetch_has_many, #fetch_has_many_with_attributes, #fetch_has_one, #fetch_has_one_with_attributes, #fetch_with_attributes, #fetch_with_url, #filtered_updatable_attributes, #has_association?, #has_associations_to_fetch?, included, #normalize_sync_url, #set_attributes_from_response, #sync_url, #update, #update!, #update_storage, #update_with_url

Methods included from ModelAssociationMixin

#_bags, #bag_key_for, #bags_attributes, #save!

Methods included from ModelBaseMixin

#assign_attribute, #assign_attributes, #attributes_hash, #clone, #delete, #has_attribute?, included, #inspect, #model_name, #new_record?, #persisted?, #save, #save!, #store

Methods included from HasNormalizer

#debug_info, #element?, #normalize_object, #normalize_options, #normalize_value

Methods included from HasAuthorization

#api_client, #current_user, #reset_current_user, #user_signed_in?

Instance Method Details

#deallocObject



36
37
38
39
# File 'motion-prime/models/model.rb', line 36

def dealloc
  Prime.logger.dealloc_message :model, self
  super
end

#errorsObject



24
25
26
# File 'motion-prime/models/model.rb', line 24

def errors
  @errors ||= Errors.new(self.weak_ref)
end

#set_errors(data) ⇒ Object



28
29
30
31
32
33
34
# File 'motion-prime/models/model.rb', line 28

def set_errors(data)
  errors.track_changed do
    data.symbolize_keys.each do |key, error_messages|
      errors.set(key, error_messages, silent: true) if error_messages.present?
    end
  end
end