Sha256: f8e6457fefc73a4eb2702f2ae270f36cf71d0218d4b0cf59f8245e5f3d0962fa

Contents?: true

Size: 742 Bytes

Versions: 3

Compression:

Stored size: 742 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|
                value.respond_to?(:call) ?
                    value.call(*[t, args].slice(0, value.arity)) :
                    value
              end
              task.send(parameter.writer_method, resolved_value)
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rake_factory-0.4.0 lib/rake_factory/parameter_view.rb
rake_factory-0.3.0 lib/rake_factory/parameter_view.rb
rake_factory-0.2.0 lib/rake_factory/parameter_view.rb