Sha256: caaa379b38ed1ee5ad27481a8612920d7ac014daa126351956843db461882c2f

Contents?: true

Size: 888 Bytes

Versions: 33

Compression:

Stored size: 888 Bytes

Contents

require_relative 'parameter_set'

module RakeFactory
  module Parameters
    def self.included(base)
      base.extend(ClassMethods)
    end

    def initialize(*args, &configuration_block)
      arity = self.method(:initialize).super_method.arity
      super(*args.slice(0, arity), &configuration_block)
      setup_parameter_defaults
    end

    def parameter_values
      self.class.parameter_set.read_from(self)
    end

    def setup_parameter_defaults
      self.class.parameter_set.apply_defaults_to(self)
    end

    def check_parameter_requirements
      self.class.parameter_set.enforce_requirements_on(self)
    end

    module ClassMethods
      def parameter_set
        @parameter_set ||= ParameterSet.new
      end

      def parameter(name, options = {})
        parameter = parameter_set.add(name, options)
        parameter.define_on(self)
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
rake_factory-0.17.0 lib/rake_factory/parameters.rb
rake_factory-0.16.0.pre.1 lib/rake_factory/parameters.rb
rake_factory-0.15.0 lib/rake_factory/parameters.rb
rake_factory-0.14.0.pre.1 lib/rake_factory/parameters.rb
rake_factory-0.13.0 lib/rake_factory/parameters.rb
rake_factory-0.12.0.pre.1 lib/rake_factory/parameters.rb
rake_factory-0.11.0 lib/rake_factory/parameters.rb
rake_factory-0.10.0.pre.1 lib/rake_factory/parameters.rb
rake_factory-0.9.0.pre.1 lib/rake_factory/parameters.rb
rake_factory-0.8.0 lib/rake_factory/parameters.rb
rake_factory-0.7.0 lib/rake_factory/parameters.rb
rake_factory-0.6.0 lib/rake_factory/parameters.rb
rake_factory-0.5.0 lib/rake_factory/parameters.rb