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



52
53
54
# File 'app/models/spree/policy.rb', line 52

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

Instance Method Details

#page_builder_urlObject



56
57
58
59
60
# File 'app/models/spree/policy.rb', line 56

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



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

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

#with_body?Boolean

Returns:

  • (Boolean)


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

def with_body?
  body.present?
end