Class: Spree::Policy

Inherits:
Object
  • Object
show all
Extended by:
FriendlyId
Includes:
TranslatableResource
Defined in:
app/models/spree/policy.rb

Constant Summary collapse

UNIQUENESS_SCOPE =
%i[owner_id owner_type].freeze
TRANSLATABLE_FIELDS =

Translations

%i[name body].freeze
RICH_TEXT_TRANSLATABLE_FIELDS =
%i[body].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TranslatableResource

#get_field_with_locale, #translatable_store, #upsert_translations

Class Method Details

.for_store(store) ⇒ Object

For policies, store.policies returns all policies owned by the store We don't want to filter out other policies in requests that use for_store when they have a different owner type



63
64
65
# File 'app/models/spree/policy.rb', line 63

def self.for_store(store)
  store.policies.or(where.not(owner_type: 'Spree::Store'))
end

Instance Method Details

#really_destroy_slugs!Object



71
72
73
# File 'app/models/spree/policy.rb', line 71

def really_destroy_slugs!
  slugs.with_deleted.each(&:really_destroy!)
end

#with_body?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'app/models/spree/policy.rb', line 67

def with_body?
  body.present?
end