Class: Redistat::Finder
- Inherits:
-
Object
- Object
- Redistat::Finder
- Includes:
- Database
- Defined in:
- lib/redistat/finder.rb,
lib/redistat/finder/date_set.rb
Defined Under Namespace
Classes: DateSet
Instance Attribute Summary (collapse)
-
- (Object) options
readonly
Returns the value of attribute options.
Class Method Summary (collapse)
- + (Object) date
- + (Object) dates(from, till)
- + (Object) depth(unit)
- + (Object) find(*args)
- + (Object) from(date)
- + (Object) interval(unit)
- + (Object) label(label)
- + (Object) scope(scope)
- + (Object) till(date)
- + (Object) untill
Instance Method Summary (collapse)
- - (Object) all(reload = false)
- - (Object) children
- - (Object) connection_ref(ref = nil)
- - (Object) dates(start, finish) (also: #date)
- - (Object) depth(unit = nil)
- - (Object) each(&block)
- - (Object) each_with_index(&block)
- - (Object) find(opts = {})
- - (Object) from(date = nil)
-
- (Finder) initialize(opts = {})
constructor
A new instance of Finder.
- - (Object) interval(unit = nil)
- - (Object) label(input = nil)
- - (Object) map(&block)
- - (Object) parent
- - (Object) scope(input = nil)
- - (Object) till(date = nil) (also: #until)
- - (Object) total
Methods included from Database
Constructor Details
- (Finder) initialize(opts = {})
A new instance of Finder
45 46 47 |
# File 'lib/redistat/finder.rb', line 45 def initialize(opts = {}) (opts) end |
Instance Attribute Details
- (Object) options (readonly)
Returns the value of attribute options
43 44 45 |
# File 'lib/redistat/finder.rb', line 43 def @options ||= {} end |
Class Method Details
+ (Object) date
23 24 25 |
# File 'lib/redistat/finder.rb', line 23 def dates(from, till) new.dates(from, till) end |
+ (Object) dates(from, till)
20 21 22 |
# File 'lib/redistat/finder.rb', line 20 def dates(from, till) new.dates(from, till) end |
+ (Object) depth(unit)
34 35 36 |
# File 'lib/redistat/finder.rb', line 34 def depth(unit) new.depth(unit) end |
+ (Object) find(*args)
8 9 10 |
# File 'lib/redistat/finder.rb', line 8 def find(*args) new.find(*args) end |
+ (Object) from(date)
25 26 27 |
# File 'lib/redistat/finder.rb', line 25 def from(date) new.from(date) end |
+ (Object) interval(unit)
38 39 40 |
# File 'lib/redistat/finder.rb', line 38 def interval(unit) new.interval(unit) end |
+ (Object) label(label)
16 17 18 |
# File 'lib/redistat/finder.rb', line 16 def label(label) new.label(label) end |
+ (Object) scope(scope)
12 13 14 |
# File 'lib/redistat/finder.rb', line 12 def scope(scope) new.scope(scope) end |
+ (Object) till(date)
29 30 31 |
# File 'lib/redistat/finder.rb', line 29 def till(date) new.till(date) end |
+ (Object) untill
32 33 34 |
# File 'lib/redistat/finder.rb', line 32 def till(date) new.till(date) end |
Instance Method Details
- (Object) all(reload = false)
53 54 55 56 |
# File 'lib/redistat/finder.rb', line 53 def all(reload = false) @result = nil if reload @result ||= find end |
- (Object) children
78 79 80 81 82 |
# File 'lib/redistat/finder.rb', line 78 def children build_key.children.map { |key| self.class.new(.merge(:label => key.label.to_s)) } end |
- (Object) connection_ref(ref = nil)
84 85 86 87 88 89 |
# File 'lib/redistat/finder.rb', line 84 def connection_ref(ref = nil) return [:connection_ref] if ref.nil? reset! if [:connection_ref] != ref [:connection_ref] = ref self end |
- (Object) dates(start, finish) Also known as: date
105 106 107 |
# File 'lib/redistat/finder.rb', line 105 def dates(start, finish) from(start).till(finish) end |
- (Object) depth(unit = nil)
125 126 127 128 129 130 |
# File 'lib/redistat/finder.rb', line 125 def depth(unit = nil) return [:depth] if unit.nil? reset! if [:depth] != unit [:depth] = unit self end |
- (Object) each(&block)
62 63 64 |
# File 'lib/redistat/finder.rb', line 62 def each(&block) all.each(&block) end |
- (Object) each_with_index(&block)
70 71 72 |
# File 'lib/redistat/finder.rb', line 70 def each_with_index(&block) all.each_with_index(&block) end |
- (Object) find(opts = {})
139 140 141 142 143 144 145 146 147 |
# File 'lib/redistat/finder.rb', line 139 def find(opts = {}) (opts) raise InvalidOptions.new if ! if [:interval].nil? || ![:interval] find_by_magic else find_by_interval end end |
- (Object) from(date = nil)
110 111 112 113 114 115 |
# File 'lib/redistat/finder.rb', line 110 def from(date = nil) return [:from] if date.nil? reset! if [:from] != date [:from] = date self end |
- (Object) interval(unit = nil)
132 133 134 135 136 137 |
# File 'lib/redistat/finder.rb', line 132 def interval(unit = nil) return [:interval] if unit.nil? reset! if [:interval] != unit [:interval] = unit self end |
- (Object) label(input = nil)
98 99 100 101 102 103 |
# File 'lib/redistat/finder.rb', line 98 def label(input = nil) return [:label] if input.nil? reset! if .has_key?(:label) && [:label].to_s != input.to_s [:label] = (!input.nil?) ? Label.new(input) : nil self end |
- (Object) map(&block)
66 67 68 |
# File 'lib/redistat/finder.rb', line 66 def map(&block) all.map(&block) end |
- (Object) parent
74 75 76 |
# File 'lib/redistat/finder.rb', line 74 def parent @parent ||= self.class.new(.merge(:label => [:label].parent)) unless [:label].nil? end |
- (Object) scope(input = nil)
91 92 93 94 95 96 |
# File 'lib/redistat/finder.rb', line 91 def scope(input = nil) return [:scope] if input.nil? reset! if ![:scope].nil? && [:scope].to_s != input.to_s [:scope] = Scope.new(input) self end |
- (Object) till(date = nil) Also known as: until
117 118 119 120 121 122 |
# File 'lib/redistat/finder.rb', line 117 def till(date = nil) return [:till] if date.nil? reset! if [:till] != date [:till] = date self end |
- (Object) total
58 59 60 |
# File 'lib/redistat/finder.rb', line 58 def total all.total end |