module Sequel::Plugins::ActiveModel::InstanceMethods

  1. lib/sequel/plugins/active_model.rb

Public Instance methods

after_destroy()

Record that an object was destroyed, for later use by destroyed?

[show source]
   # File lib/sequel/plugins/active_model.rb
49 def after_destroy
50   super
51   @destroyed = true
52 end
model_name()

Return ::ActiveModel::Name instance for the class.

[show source]
   # File lib/sequel/plugins/active_model.rb
55 def model_name
56   model.model_name
57 end
persisted?()

False if the object is new? or has been destroyed, true otherwise.

[show source]
   # File lib/sequel/plugins/active_model.rb
60 def persisted?
61   return false if new?
62   return false if defined?(@destroyed)
63 
64   if defined?(@rollback_checker)
65     if @rollback_checker.call
66       return false
67     end
68   end
69   
70   true
71 end
to_key()

An array of primary key values, or nil if the object is not persisted.

[show source]
   # File lib/sequel/plugins/active_model.rb
74 def to_key
75   if primary_key.is_a?(Symbol)
76     [pk] if pk
77   else
78     pk if pk.all?
79   end
80 end
to_model()

With the active_model plugin, Sequel model objects are already compliant, so this returns self.

[show source]
   # File lib/sequel/plugins/active_model.rb
84 def to_model
85   self
86 end
to_param()

An string representing the object's primary key. For composite primary keys, joins them with to_param_joiner.

[show source]
   # File lib/sequel/plugins/active_model.rb
90 def to_param
91   if persisted? and k = to_key
92     k.join(to_param_joiner)
93   end
94 end
to_partial_path()

Returns a string identifying the path associated with the object.

[show source]
   # File lib/sequel/plugins/active_model.rb
97 def to_partial_path
98   model._to_partial_path
99 end