Sha256: 8d742a8fd124d2ab4bf7e99ae981a3775f5c3e6135657b0a223edffcb67c0afd

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

module Scorpion
  # An injected attribute and it's configuration.
  class Attribute

    # ============================================================================
    # @!group Attributes
    #

    # @!attribute
    # @return [Symbol] the name of the attribute.
      attr_reader :name

    # @!attribute
    # @return [Class,Module,Symbol] contract that describes the desired behavior
    #   of the injected object.
      def contract
        @contract = @contract.constantize if @contract.is_a? String
        @contract
      end

    # @!attribute
    # @return [Boolean] true if the attribute is not immediately required and
    #   will be hunted down on first use.
      def lazy?
        @lazy
      end

    # @!attribute
    # @return [Boolean] true if the attribute should have a public writer.
      def public?
        @public
      end

    # @!attribute
    # @return [Boolean] true if the attribute should have a public writer.
      def private?
        @private
      end

    #
    # @!endgroup Attributes


    def initialize( name, contract, lazy: false, public: false, private: false )
      @name      = name.to_sym
      @contract  = contract
      @lazy      = lazy
      @public    = public
      @private   = private
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
scorpion-ioc-1.0.10 lib/scorpion/attribute.rb
scorpion-ioc-1.0.8 lib/scorpion/attribute.rb
scorpion-ioc-1.0.7 lib/scorpion/attribute.rb
scorpion-ioc-1.0.6 lib/scorpion/attribute.rb
scorpion-ioc-1.0.4 lib/scorpion/attribute.rb
scorpion-ioc-1.0.3 lib/scorpion/attribute.rb
scorpion-ioc-1.0.2 lib/scorpion/attribute.rb
scorpion-ioc-1.0.1 lib/scorpion/attribute.rb
scorpion-ioc-1.0.0 lib/scorpion/attribute.rb