Sha256: f474d30414d9d90ac947e5ed6403d881fcae62615ec82919ebb0c3e59a7684a4

Contents?: true

Size: 845 Bytes

Versions: 2

Compression:

Stored size: 845 Bytes

Contents

module ControllerResourceClass
  module Able
    extend ActiveSupport::Concern

    def resource_class
      self.class.resource_class
    end

    included do
      helper_method :resource_class
    end

    module ClassMethods
      def set_resource_class(value)
        self.resource_class_name = value
      end

      def resource_class
        return nil if resource_class_name == false
        self.resource_class_name = Controller.new(self).resource_class_name unless resource_class_name
        resource_class_name.constantize
      end

    private
      def resource_class_name=(value)
        @resource_class_name = case value
          when false then false
          when String, Class then String(value)
          else 
        end
      end

      def resource_class_name
        @resource_class_name
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
controller_resource_class-0.0.4 lib/controller_resource_class/able.rb
controller_resource_class-0.0.3 lib/controller_resource_class/able.rb