Sha256: 391584aeaa310d96e5e063734d33b27d341995c1a059d989ec1e24522415a921

Contents?: true

Size: 908 Bytes

Versions: 1

Compression:

Stored size: 908 Bytes

Contents

module CanTango
  module Factory
    class Permits
      include CanTango::Helpers::Debug

      attr_accessor :ability
      attr_reader :type

      # creates the factory for the ability
      # note that the ability contains the roles and role groups of the user (or account)
      # @param [Permits::Ability] the ability
      def initialize ability, type
        @ability, @type = [ability, type]
      end

      def create
        permits.build
      end

      def permits
        permits_builder.new ability
      end
      
      def permits_builder
        permits_builder_class.constantize
      end

      def permits_builder_class
        return "CanTango::Builder::Permit::Special" if type == :special
        "CanTango::Builder::Permit::#{type.to_s.camelize}"
      end

      protected

      def enabled_permit_types
        CanTango.config.permits.types.enabled
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-permits-0.1.1 lib/cantango/permits_ext/factory/permits.rb