Sha256: a6c80bcaf470873687ca2336221f9540b7428e5628c9e43ae0a12cb0675adbdd

Contents?: true

Size: 405 Bytes

Versions: 3

Compression:

Stored size: 405 Bytes

Contents

module Julia
  class Action
    attr_reader :key, :action, :block

    def initialize(key, action = nil, &block)
      @action = action
      @block  = block
      @key    = key
    end

    def get_value(record, host)
      return host.instance_exec(record, &block) if block
      return record.instance_exec(&action) if action.is_a? Proc

      record.send [action, key].compact.first
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
julia_builder-0.2.2 lib/julia/action.rb
julia_builder-0.2.1 lib/julia/action.rb
julia_builder-0.2.0 lib/julia/action.rb