Sha256: ca6a7031405fb76d9b5fe25c7eaea068bfd20f8fda6db81cefd85f0847e23383
Contents?: true
Size: 929 Bytes
Versions: 4
Compression:
Stored size: 929 Bytes
Contents
module BB module Evaluator class Table EVALUATE_TYPES = %i(subquery table_date table_date_range plain).freeze attr_reader :value, :options def initialize(value, options = {}) @value = value @options = options end def eval_type EVALUATE_TYPES.detect { |type| send("#{type}?") } end private def subquery? value.respond_to?(:to_sql) end def table_date? !value.to_s.empty? && options[:on].respond_to?(:strftime) end def table_date_range? !value.to_s.empty? && options[:from].respond_to?(:strftime) && options[:to].respond_to?(:strftime) end def plain? !value.to_s.empty? && !table_date? && !table_date_range? && !subquery? end class << self def eval_type(value, options = {}) new(value, options).eval_type end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
b_b-0.1.3 | lib/b_b/evaluator/table.rb |
b_b-0.1.2 | lib/b_b/evaluator/table.rb |
b_b-0.1.1 | lib/b_b/evaluator/table.rb |
b_b-0.1.0 | lib/b_b/evaluator/table.rb |