Sha256: b558247127655369a7d59b0b9f146451b3133c4c3ced5396dbcb41f896df5ad4

Contents?: true

Size: 716 Bytes

Versions: 3

Compression:

Stored size: 716 Bytes

Contents

# frozen_string_literal: true

module BeyondCanvas
  module ResourceManagement # :nodoc:
    extend ActiveSupport::Concern

    included do
      # Share some methods defined in the controller to make them available for the view
      if respond_to?(:helper_method)
        helpers = %w[resource resource_name resource_class]
        helper_method(*helpers)
      end
    end

    protected

    def resource_name
      BeyondCanvas.auth_model
    end

    def resource
      instance_variable_get(:"@#{resource_name}")
    end

    def resource=(new_resource)
      instance_variable_set(:"@#{resource_name}", new_resource)
    end

    def resource_class
      resource_name.classify.constantize
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
beyond_canvas-0.16.2.pre app/controllers/concerns/beyond_canvas/resource_management.rb
beyond_canvas-0.16.1.pre app/controllers/concerns/beyond_canvas/resource_management.rb
beyond_canvas-0.16.0.pre app/controllers/concerns/beyond_canvas/resource_management.rb