Sha256: be91d87ab8f0985cc13bb32bb22452643a67984bd74e6d010f5affff6cdf5c6a

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

module CanTango
  class Configuration
    class RoleRegistry < Registry
      attr_reader :has_method, :list_method

      [:has_method, :list_method].each do |meth|
        class_eval %{
          def #{meth}
            @#{meth} ||= default_#{meth}
          end

          def #{meth}= name
            raise "Must be a label" if !name.kind_of_label?
            @#{meth} = name
          end
        }
      end

      def only *names
        @onlies = names.select_labels
      end

      def onlies
        @onlies ||= []
      end

      def excluded
        @excluded ||= []
      end

      def exclude *names
        @excluded = names.select_labels
      end

      def clear!
        super
        @excluded = []
        @onlies = []
      end      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-0.8.0 lib/cantango/configuration/role_registry.rb