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:



171
172
173
174
# File 'lib/activerecord_instance_methods.rb', line 171

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:



165
166
167
168
# File 'lib/activerecord_instance_methods.rb', line 165

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