Module: Bmg::Algebra
- Includes:
- Algebra::Shortcuts
- Included in:
- Relation
- Defined in:
- lib/bmg/algebra.rb,
lib/bmg/algebra/shortcuts.rb
Defined Under Namespace
Modules: Shortcuts
Instance Method Summary collapse
- #allbut(butlist = []) ⇒ Object
- #autosummarize(by = [], summarization = {}, options = {}) ⇒ Object
- #autowrap(options = {}) ⇒ Object
- #constants(cs = {}) ⇒ Object
- #extend(extension = {}) ⇒ Object
- #group(attrs, as = :group, options = {}) ⇒ Object
- #image(right, as = :image, on = [], options = {}) ⇒ Object
- #join(right, on = []) ⇒ Object
- #left_join(right, on = [], default_right_tuple = {}) ⇒ Object
- #matching(right, on = []) ⇒ Object
- #materialize ⇒ Object
- #minus(other) ⇒ Object
- #not_matching(right, on = []) ⇒ Object
- #page(ordering, page_index, options) ⇒ Object
- #project(attrlist = []) ⇒ Object
- #rename(renaming = {}) ⇒ Object
- #restrict(predicate) ⇒ Object
- #spied(spy) ⇒ Object
- #summarize(by, summarization = {}) ⇒ Object
- #transform(transformation = nil, options = {}, &proc) ⇒ Object
- #undress(options = {}) ⇒ Object
- #ungroup(attrs) ⇒ Object
- #union(other, options = {}) ⇒ Object
- #unspied ⇒ Object
- #unwrap(attrs) ⇒ Object
Instance Method Details
#allbut(butlist = []) ⇒ Object
4 5 6 7 |
# File 'lib/bmg/algebra.rb', line 4 def allbut(butlist = []) return self if butlist.empty? _allbut self.type.allbut(butlist), butlist end |
#autosummarize(by = [], summarization = {}, options = {}) ⇒ Object
24 25 26 |
# File 'lib/bmg/algebra.rb', line 24 def autosummarize(by = [], summarization = {}, = {}) _autosummarize self.type.autosummarize(by, summarization, ), by, summarization, end |
#autowrap(options = {}) ⇒ Object
14 15 16 17 |
# File 'lib/bmg/algebra.rb', line 14 def autowrap( = {}) return self if self.type.identity_autowrap?() _autowrap self.type.autowrap(), end |
#constants(cs = {}) ⇒ Object
33 34 35 |
# File 'lib/bmg/algebra.rb', line 33 def constants(cs = {}) _constants self.type.constants(cs), cs end |
#extend(extension = {}) ⇒ Object
42 43 44 45 |
# File 'lib/bmg/algebra.rb', line 42 def extend(extension = {}) return self if extension.empty? _extend self.type.extend(extension), extension end |
#group(attrs, as = :group, options = {}) ⇒ Object
52 53 54 |
# File 'lib/bmg/algebra.rb', line 52 def group(attrs, as = :group, = {}) _group self.type.group(attrs, as), attrs, as, end |
#image(right, as = :image, on = [], options = {}) ⇒ Object
61 62 63 |
# File 'lib/bmg/algebra.rb', line 61 def image(right, as = :image, on = [], = {}) _image self.type.image(right.type, as, on, ), right, as, on, end |
#join(right, on = []) ⇒ Object
70 71 72 |
# File 'lib/bmg/algebra.rb', line 70 def join(right, on = []) _join self.type.join(right.type, on), right, on end |
#left_join(right, on = [], default_right_tuple = {}) ⇒ Object
84 85 86 87 |
# File 'lib/bmg/algebra.rb', line 84 def left_join(right, on = [], default_right_tuple = {}) drt = default_right_tuple _left_join self.type.left_join(right.type, on, drt), right, on, drt end |
#matching(right, on = []) ⇒ Object
97 98 99 |
# File 'lib/bmg/algebra.rb', line 97 def matching(right, on = []) _matching self.type.matching(right.type, on), right, on end |
#materialize ⇒ Object
243 244 245 |
# File 'lib/bmg/algebra.rb', line 243 def materialize Relation::Materialized.new(self) end |
#minus(other) ⇒ Object
215 216 217 218 |
# File 'lib/bmg/algebra.rb', line 215 def minus(other) return self if other.is_a?(Relation::Empty) _minus self.type.minus(other.type), other end |
#not_matching(right, on = []) ⇒ Object
106 107 108 |
# File 'lib/bmg/algebra.rb', line 106 def not_matching(right, on = []) _not_matching self.type.not_matching(right.type, on), right, on end |
#page(ordering, page_index, options) ⇒ Object
115 116 117 |
# File 'lib/bmg/algebra.rb', line 115 def page(ordering, page_index, ) _page self.type.page(ordering, page_index, ), ordering, page_index, end |
#project(attrlist = []) ⇒ Object
124 125 126 |
# File 'lib/bmg/algebra.rb', line 124 def project(attrlist = []) _project self.type.project(attrlist), attrlist end |
#rename(renaming = {}) ⇒ Object
133 134 135 136 137 |
# File 'lib/bmg/algebra.rb', line 133 def rename(renaming = {}) renaming = renaming.reject{|k,v| k==v } return self if renaming.empty? _rename self.type.rename(renaming), renaming end |
#restrict(predicate) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/bmg/algebra.rb', line 144 def restrict(predicate) predicate = Predicate.coerce(predicate) if predicate.tautology? self else type = self.type.restrict(predicate) if predicate.contradiction? Relation.empty(type) else begin _restrict type, predicate rescue Predicate::NotSupportedError Operator::Restrict.new(type, self, predicate) end end end end |
#spied(spy) ⇒ Object
234 235 236 237 |
# File 'lib/bmg/algebra.rb', line 234 def spied(spy) return self if spy.nil? Relation::Spied.new(self, spy) end |
#summarize(by, summarization = {}) ⇒ Object
167 168 169 |
# File 'lib/bmg/algebra.rb', line 167 def summarize(by, summarization = {}) _summarize self.type.summarize(by, summarization), by, summarization end |
#transform(transformation = nil, options = {}, &proc) ⇒ Object
176 177 178 179 180 |
# File 'lib/bmg/algebra.rb', line 176 def transform(transformation = nil, = {}, &proc) transformation, = proc, (transformation || {}) unless proc.nil? return self if transformation.is_a?(Hash) && transformation.empty? _transform(self.type.transform(transformation, ), transformation, ) end |
#undress(options = {}) ⇒ Object
187 188 189 |
# File 'lib/bmg/algebra.rb', line 187 def undress( = {}) _undress self.type.undress(), end |
#ungroup(attrs) ⇒ Object
196 197 198 |
# File 'lib/bmg/algebra.rb', line 196 def ungroup(attrs) _ungroup self.type.ungroup(attrs), attrs end |
#union(other, options = {}) ⇒ Object
205 206 207 208 |
# File 'lib/bmg/algebra.rb', line 205 def union(other, = {}) return self if other.is_a?(Relation::Empty) _union self.type.union(other.type), other, end |
#unspied ⇒ Object
239 240 241 |
# File 'lib/bmg/algebra.rb', line 239 def unspied self end |
#unwrap(attrs) ⇒ Object
225 226 227 |
# File 'lib/bmg/algebra.rb', line 225 def unwrap(attrs) _unwrap self.type.unwrap(attrs), attrs end |