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

Methods

Constants

DEFAULT_TO_PARAM_JOINER = '-'.freeze   The default string to join composite primary keys with in to_param.

Public Instance methods

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 34
34:         def after_destroy
35:           super
36:           @destroyed = true
37:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 40
40:         def persisted?
41:           !new? && @destroyed != true
42:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 45
45:         def to_key
46:           if primary_key.is_a?(Symbol)
47:             [pk] if pk
48:           else
49:             pk if pk.all?
50:           end
51:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 55
55:         def to_model
56:           self
57:         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 61
61:         def to_param
62:           if persisted? and k = to_key
63:             k.join(to_param_joiner)
64:           end
65:         end

Returns a string identifying the path associated with the object.

[Source]

    # File lib/sequel/plugins/active_model.rb, line 68
68:         def to_partial_path
69:           model._to_partial_path
70:         end

[Validate]