mirror of
https://github.com/jimeh/redistat.git
synced 2026-02-19 05:16:39 +00:00
make Finder work with Scope and Label objects rather than strings
This commit is contained in:
@@ -72,14 +72,14 @@ module Redistat
|
||||
end
|
||||
|
||||
def scope(scope)
|
||||
reset! if @options[:scope] != scope
|
||||
@options[:scope] = scope
|
||||
reset! if @options[:scope].to_s != scope
|
||||
@options[:scope] = Scope.new(scope)
|
||||
self
|
||||
end
|
||||
|
||||
def label(label)
|
||||
reset! if @options[:label] != label
|
||||
@options[:label] = label
|
||||
reset! if @options[:label].raw != label
|
||||
@options[:label] = Label.new(label)
|
||||
self
|
||||
end
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
module Redistat
|
||||
class Key
|
||||
|
||||
attr_accessor :scope
|
||||
attr_accessor :date
|
||||
attr_accessor :options
|
||||
|
||||
def initialize(scope, label_name = nil, time_stamp = nil, options = {})
|
||||
@options = default_options.merge(options || {})
|
||||
@scope = scope
|
||||
self.scope = scope
|
||||
self.label = label_name if !label_name.nil?
|
||||
self.date = time_stamp ||= Time.now
|
||||
end
|
||||
@@ -35,6 +34,10 @@ module Redistat
|
||||
@label.name
|
||||
end
|
||||
|
||||
def label=(input)
|
||||
@label = (input.instance_of?(Redistat::Label)) ? input : Label.create(input, @options)
|
||||
end
|
||||
|
||||
def label_hash
|
||||
@label.hash
|
||||
end
|
||||
@@ -43,8 +46,12 @@ module Redistat
|
||||
@label.groups
|
||||
end
|
||||
|
||||
def label=(input)
|
||||
@label = (input.instance_of?(Redistat::Label)) ? input : Label.create(input, @options)
|
||||
def scope
|
||||
@scope.to_s
|
||||
end
|
||||
|
||||
def scope=(input)
|
||||
@scope = (input.instance_of?(Redistat::Scope)) ? input : Scope.new(input)
|
||||
end
|
||||
|
||||
def groups
|
||||
|
||||
Reference in New Issue
Block a user