module Bmg::Algebra::Shortcuts
Public Instance Methods
exclude(predicate)
click to toggle source
# File lib/bmg/algebra/shortcuts.rb, line 9 def exclude(predicate) restrict(!Predicate.coerce(predicate)) end
image(right, as = :image, on = [], options = {})
click to toggle source
Calls superclass method
# File lib/bmg/algebra/shortcuts.rb, line 36 def image(right, as = :image, on = [], options = {}) return super unless on.is_a?(Hash) renaming = Hash[on.map{|k,v| [v,k] }] self.image(right.rename(renaming), as, on.keys, options) end
images(rights, on = [], options = {})
click to toggle source
# File lib/bmg/algebra/shortcuts.rb, line 42 def images(rights, on = [], options = {}) rights.each_pair.inject(self){|memo,(as,right)| memo.image(right, as, on, options) } end
join(right, on = [])
click to toggle source
Calls superclass method
# File lib/bmg/algebra/shortcuts.rb, line 48 def join(right, on = []) return super unless on.is_a?(Hash) renaming = Hash[on.map{|k,v| [v,k] }] self.join(right.rename(renaming), on.keys) end
left_join(right, on = [], *args)
click to toggle source
Calls superclass method
# File lib/bmg/algebra/shortcuts.rb, line 54 def left_join(right, on = [], *args) return super unless on.is_a?(Hash) renaming = Hash[on.map{|k,v| [v,k] }] self.left_join(right.rename(renaming), on.keys, *args) end
matching(right, on = [])
click to toggle source
Calls superclass method
# File lib/bmg/algebra/shortcuts.rb, line 60 def matching(right, on = []) return super unless on.is_a?(Hash) renaming = Hash[on.map{|k,v| [v,k] }] self.matching(right.rename(renaming), on.keys) end
not_matching(right, on = [])
click to toggle source
Calls superclass method
# File lib/bmg/algebra/shortcuts.rb, line 66 def not_matching(right, on = []) return super unless on.is_a?(Hash) renaming = Hash[on.map{|k,v| [v,k] }] self.not_matching(right.rename(renaming), on.keys) end
prefix(prefix, options = {})
click to toggle source
# File lib/bmg/algebra/shortcuts.rb, line 20 def prefix(prefix, options = {}) raise "Attrlist must be known to use `prefix`" unless self.type.knows_attrlist? attrs = self.type.to_attrlist attrs = attrs - options[:but] if options[:but] renaming = Hash[attrs.map{|a| [a, :"#{prefix}#{a}"] }] self.rename(renaming) end
rxmatch(attrs, matcher, options = {})
click to toggle source
# File lib/bmg/algebra/shortcuts.rb, line 13 def rxmatch(attrs, matcher, options = {}) predicate = attrs.inject(Predicate.contradiction){|p,a| p | Predicate.match(a, matcher, options) } self.restrict(predicate) end
suffix(suffix, options = {})
click to toggle source
# File lib/bmg/algebra/shortcuts.rb, line 28 def suffix(suffix, options = {}) raise "Attrlist must be known to use `suffix`" unless self.type.knows_attrlist? attrs = self.type.to_attrlist attrs = attrs - options[:but] if options[:but] renaming = Hash[attrs.map{|a| [a, :"#{a}#{suffix}"] }] self.rename(renaming) end
ungroup(attr)
click to toggle source
Calls superclass method
# File lib/bmg/algebra/shortcuts.rb, line 72 def ungroup(attr) super(attr.is_a?(Symbol) ? [attr] : attr) end
unwrap(attr)
click to toggle source
Calls superclass method
# File lib/bmg/algebra/shortcuts.rb, line 76 def unwrap(attr) super(attr.is_a?(Symbol) ? [attr] : attr) end
where(predicate)
click to toggle source
# File lib/bmg/algebra/shortcuts.rb, line 5 def where(predicate) restrict(predicate) end