Skip to content
This repository was archived by the owner on May 18, 2024. It is now read-only.
This repository was archived by the owner on May 18, 2024. It is now read-only.

Specify an alternative location for access class #10

@storm255

Description

@storm255

Thank you for your efforts with this gem.

I may be missing something obvious, but ideally I would like to arrange my access classes into another folder as they grow. I have tried to use the source_class method on the originating class but without success.

Playing with the gem I managed to get what I needed working temporarily by adding another line to the registry

# vendor/gems/allowy-1.0.0/lib/allowy/registry.rb

    def access_control_for(subject)
      # Local modification: Allow specifying the access class directly
      clazz = subject.class.authorisation_class if subject.class.respond_to?(:authorisation_class)

and then just adding a direct reference to the target access class with

# models/actions/cancel_deposit.rb

  def self.authorisation_class
    Authorisations::CancelDepositAccess
  end

# models/authorisations/cancel_deposit_access.rb
class Authorisations::CancelDepositAccess
  include Allowy::AccessControl
  def cancel_deposit?(cd)
    context.signed_in?
  end
end

Is this heading in the right direction or is there a way to work with the library?

Cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions