Class: Spree::Policy

Inherits:
Object
  • Object
show all
Extended by:
FriendlyId
Includes:
Linkable, 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



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

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

Instance Method Details

#page_builder_urlObject



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

def page_builder_url
  return unless Spree::Core::Engine.routes.url_helpers.respond_to?(:policy_path)

  Spree::Core::Engine.routes.url_helpers.policy_path(self)
end

#really_destroy_slugs!Object



75
76
77
# File 'app/models/spree/policy.rb', line 75

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

#with_body?Boolean

Returns:

  • (Boolean)


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

def with_body?
  body.present?
end