Sha256: 93a3ee91c916cbc516cb9954a1f6cdeb9c49af456e61792f690831d91027a38b

Contents?: true

Size: 547 Bytes

Versions: 11

Compression:

Stored size: 547 Bytes

Contents

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

    def process_arguments(args)
      opts = args.first || {}
      opts.each { |key, value| set_if_value_present(key, value) }
    end

    private

    def set_if_value_present(key, value)
      if self.respond_to?("#{key}=") && !value.nil?
        self.send("#{key}=", value)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

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