Sha256: 2efd05d8fcdc4d4a5537d2c2ab87f01ff2cd3a4cd0f9fd6e11cd648303da0d7d

Contents?: true

Size: 929 Bytes

Versions: 5

Compression:

Stored size: 929 Bytes

Contents

module Influxer
  module FanoutQuery
    # Instance methods are included to Relation    
    def build_fanout(key, val)
      @values[:has_fanout] = true
      if val.is_a?(Regexp)
        @values[:fanout_rxp] = true
        fanout_values[key.to_s] = val.inspect[1..-2]     
      else
        fanout_values[key.to_s] = val.to_s
      end
    end

    def build_series_name
      if @values[:has_fanout] == true
        fan_parts = [@instance.series[1..-2]]
        @klass.fanouts.each do |name|
          if fanout_values.key?(name)
            fan_parts << name
            fan_parts << fanout_values[name]
          end
        end  
        if @values[:fanout_rxp] == true
          "merge(/^#{ fan_parts.join( @klass.fanout_options[:delimeter] ) }$/)"
        else
          @instance.quote_series(fan_parts.join(@klass.fanout_options[:delimeter]))
        end
      else
        @instance.series
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
influxer-0.2.2 lib/influxer/metrics/relation/fanout_query.rb
influxer-0.2.0 lib/influxer/metrics/relation/fanout_query.rb
influxer-0.1.2 lib/influxer/metrics/relation/fanout_query.rb
influxer-0.1.1 lib/influxer/metrics/relation/fanout_query.rb
influxer-0.1.0 lib/influxer/metrics/relation/fanout_query.rb