Sha256: fa29369f812570bde7afd3a1ac17efdd155027c2940e028e22e5288d537c638b

Contents?: true

Size: 447 Bytes

Versions: 9

Compression:

Stored size: 447 Bytes

Contents

module TableHelp
  class Strategy
    attr_reader :name, :symbol_or_proc

    def initialize(name, symbol_or_proc)
      @name = name
      @symbol_or_proc = symbol_or_proc
    end

    def to_value(record, context = nil)
      case symbol_or_proc
      when Symbol, String
        record.send(symbol_or_proc)
      when Proc
        context.capture { symbol_or_proc.call(record) }
      else
        record.send(name)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
table_help-0.2.0 lib/table_help/strategy.rb
table_help-0.1.7 lib/table_help/strategy.rb
table_help-0.1.6 lib/table_help/strategy.rb
table_help-0.1.5 lib/table_help/strategy.rb
table_help-0.1.4 lib/table_help/strategy.rb
table_help-0.1.3 lib/table_help/strategy.rb
table_help-0.1.2 lib/table_help/strategy.rb
table_help-0.1.1 lib/table_help/strategy.rb
table_help-0.1.0 lib/table_help/strategy.rb