Module: DraftPunk::Model::InstanceInterrogators

Defined in:
lib/activerecord_instance_methods.rb

Instance Method Summary collapse

Instance Method Details

#has_draft?Boolean

Returns whether the current ActiveRecord object has a draft version.

Returns:

  • (Boolean)

    whether the current ActiveRecord object has a draft version

Raises:



162
163
164
165
# File 'lib/activerecord_instance_methods.rb', line 162

def has_draft?
  raise DraftPunk::ApprovedVersionIdError unless respond_to?(:approved_version_id)
  draft.present?
end

#is_draft?Boolean

Returns whether the current ActiveRecord object is a draft.

Returns:

  • (Boolean)

    whether the current ActiveRecord object is a draft

Raises:



156
157
158
159
# File 'lib/activerecord_instance_methods.rb', line 156

def is_draft?
  raise DraftPunk::ApprovedVersionIdError unless respond_to?("approved_version_id")
  approved_version_id.present?
end