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 42
42:         def after_destroy
43:           super
44:           @destroyed = true
45:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 48
48:         def model_name
49:           model.model_name
50:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 53
53:         def persisted?
54:           !new? && @destroyed != true
55:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 58
58:         def to_key
59:           if primary_key.is_a?(Symbol)
60:             [pk] if pk
61:           else
62:             pk if pk.all?
63:           end
64:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 68
68:         def to_model
69:           self
70:         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 74
74:         def to_param
75:           if persisted? and k = to_key
76:             k.join(to_param_joiner)
77:           end
78:         end

Returns a string identifying the path associated with the object.

[Source]

    # File lib/sequel/plugins/active_model.rb, line 81
81:         def to_partial_path
82:           model._to_partial_path
83:         end

[Validate]