Sha256: dcbe02dfdd93cf73d9b4d1785805b65efea2c8aa3aee0a309bcaa08495c9d8e7

Contents?: true

Size: 787 Bytes

Versions: 5

Compression:

Stored size: 787 Bytes

Contents

module RakeFactory
  class ParameterView
    attr_reader(:task)

    def initialize(task, args)
      self.instance_eval do
        task.class.parameter_set.each do |parameter|
          define_singleton_method parameter.reader_method do
            task.send(parameter.reader_method)
          end

          if parameter.configurable?
            define_singleton_method parameter.writer_method do |value|
              resolved_value = lambda do |t|
                params = args ? [t, args] : [t]
                value.respond_to?(:call) ?
                    value.call(*params.slice(0, value.arity)) :
                    value
              end
              task.send(parameter.writer_method, resolved_value)
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rake_factory-0.9.0.pre.1 lib/rake_factory/parameter_view.rb
rake_factory-0.8.0 lib/rake_factory/parameter_view.rb
rake_factory-0.7.0 lib/rake_factory/parameter_view.rb
rake_factory-0.6.0 lib/rake_factory/parameter_view.rb
rake_factory-0.5.0 lib/rake_factory/parameter_view.rb