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

Class Method Summary collapse

Instance Method Summary collapse

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



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

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

Instance Method Details

#really_destroy_slugs!Object



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

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

#with_body?Boolean

Returns:

  • (Boolean)


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

def with_body?
  body.present?
end