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

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

[Source]

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

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 55
55:         def persisted?
56:           return false if new?
57:           return false if defined?(@destroyed)
58: 
59:           if defined?(@rollback_checker)
60:             if @rollback_checker.call
61:               return false
62:             end
63:           end
64:           
65:           true
66:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 69
69:         def to_key
70:           if primary_key.is_a?(Symbol)
71:             [pk] if pk
72:           else
73:             pk if pk.all?
74:           end
75:         end

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

[Source]

    # File lib/sequel/plugins/active_model.rb, line 79
79:         def to_model
80:           self
81:         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 85
85:         def to_param
86:           if persisted? and k = to_key
87:             k.join(to_param_joiner)
88:           end
89:         end

Returns a string identifying the path associated with the object.

[Source]

    # File lib/sequel/plugins/active_model.rb, line 92
92:         def to_partial_path
93:           model._to_partial_path
94:         end

[Validate]