lib/redistat/key.rb in redistat-0.0.1 vs lib/redistat/key.rb in redistat-0.0.2

- old
+ new

@@ -3,24 +3,24 @@ attr_accessor :scope attr_accessor :date attr_accessor :options - def initialize(scope, label = nil, date = nil, options = {}) + def initialize(scope, label_name = nil, time_stamp = nil, options = {}) + @options = default_options.merge(options || {}) @scope = scope - self.label = label if !label.nil? - self.date = date ||= Time.now - @options = default_options.merge(options ||= {}) + self.label = label_name if !label_name.nil? + self.date = time_stamp ||= Time.now end def default_options - { :depth => :day } + { :depth => :hour, :hashed_label => false } end def prefix key = "#{@scope}" - key << "/" + ((@options[:label_hash].nil? || @options[:label_hash] == true) ? @label.hash : @label.name) if !label.nil? + key << "/#{label}" if !label.nil? key << ":" key end def date=(input) @@ -38,10 +38,10 @@ def label_hash @label.hash end def label=(input) - @label = (input.instance_of?(Redistat::Label)) ? input : Label.create(input) + @label = (input.instance_of?(Redistat::Label)) ? input : Label.create(input, @options) end def to_s(depth = nil) depth ||= @options[:depth] key = self.prefix \ No newline at end of file