Module Sequel::Plugins::ActiveModel::InstanceMethods
In: lib/sequel/plugins/active_model.rb

Methods

Public Instance methods

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 49
49:         def after_destroy
50:           super
51:           @destroyed = true
52:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 55
55:         def model_name
56:           model.model_name
57:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 60
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

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 74
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

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 84
84:         def to_model
85:           self
86:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 90
90:         def to_param
91:           if persisted? and k = to_key
92:             k.join(to_param_joiner)
93:           end
94:         end

Returns a string identifying the path associated with the object.

[Source]

    # File lib/sequel/plugins/active_model.rb, line 97
97:         def to_partial_path
98:           model._to_partial_path
99:         end

[Validate]