Sha256: f7736d475ed4b8addef89e02a4088f7d3ad4c709da9a0ddb4da60f708b87d9ab

Contents?: true

Size: 1.64 KB

Versions: 33

Compression:

Stored size: 1.64 KB

Contents

require 'active_support'
require 'active_support/core_ext/string/inflections'

require_relative 'parameters'

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

    module ClassMethods
      include Parameters

      def inherited(inheritor)
        super(inheritor)
        inheritor.class_eval do
          parameter(:name,
              configurable: false,
              transform: lambda { |n| n.to_sym })
          parameter(:argument_names,
              configurable: false,
              default: [])
          parameter(:prerequisites,
              configurable: false,
              default: [])
          parameter(:order_only_prerequisites,
              configurable: false,
              default: [])
          parameter(:description,
              configurable: false)

          unless inheritor.name.nil?
            default_name inheritor.name.demodulize.underscore
          end
        end
      end

      def default_name(name)
        parameter_set.update_default_for(:name, name)
      end

      def default_argument_names(argument_names)
        parameter_set.update_default_for(:argument_names, argument_names)
      end

      def default_prerequisites(prerequisites)
        parameter_set.update_default_for(:prerequisites, prerequisites)
      end

      def default_order_only_prerequisites(order_only_prerequisites)
        parameter_set
            .update_default_for(
                :order_only_prerequisites, order_only_prerequisites)
      end

      def default_description(description)
        parameter_set.update_default_for(:description, description)
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
rake_factory-0.30.0.pre.5 lib/rake_factory/defaults.rb
rake_factory-0.30.0.pre.4 lib/rake_factory/defaults.rb
rake_factory-0.30.0.pre.3 lib/rake_factory/defaults.rb
rake_factory-0.30.0.pre.2 lib/rake_factory/defaults.rb
rake_factory-0.30.0.pre.1 lib/rake_factory/defaults.rb
rake_factory-0.29.0 lib/rake_factory/defaults.rb
rake_factory-0.28.0.pre.2 lib/rake_factory/defaults.rb
rake_factory-0.28.0.pre.1 lib/rake_factory/defaults.rb
rake_factory-0.27.0 lib/rake_factory/defaults.rb
rake_factory-0.26.0.pre.1 lib/rake_factory/defaults.rb
rake_factory-0.24.0.pre.2 lib/rake_factory/defaults.rb
rake_factory-0.25.0 lib/rake_factory/defaults.rb
rake_factory-0.24.0.pre.1 lib/rake_factory/defaults.rb
rake_factory-0.23.0 lib/rake_factory/defaults.rb
rake_factory-0.22.0.pre.1 lib/rake_factory/defaults.rb
rake_factory-0.21.0 lib/rake_factory/defaults.rb
rake_factory-0.20.0.pre.1 lib/rake_factory/defaults.rb
rake_factory-0.19.0 lib/rake_factory/defaults.rb
rake_factory-0.18.0.pre.2 lib/rake_factory/defaults.rb
rake_factory-0.18.0.pre.1 lib/rake_factory/defaults.rb