Module: Bmg::Algebra::Shortcuts

Included in:
Bmg::Algebra
Defined in:
lib/bmg/algebra/shortcuts.rb

Instance Method Summary collapse

Instance Method Details

#prefix(prefix) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/bmg/algebra/shortcuts.rb', line 12

def prefix(prefix)
  raise "Attrlist must be known to use `prefix`" unless self.type.knows_attrlist?
  renaming = self.type.to_attrlist.each_with_object({}){|a,r|
    r[a] = :"#{prefix}#{a}"
  }
  self.rename(renaming)
end

#rxmatch(attrs, matcher, options = {}) ⇒ Object



5
6
7
8
9
10
# File 'lib/bmg/algebra/shortcuts.rb', line 5

def rxmatch(attrs, matcher, options = {})
  predicate = attrs.inject(Predicate.contradiction){|p,a|
    p | Predicate.match(a, matcher, options)
  }
  self.restrict(predicate)
end

#suffix(suffix) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/bmg/algebra/shortcuts.rb', line 20

def suffix(suffix)
  raise "Attrlist must be known to use `suffix`" unless self.type.knows_attrlist?
  renaming = self.type.to_attrlist.each_with_object({}){|a,r|
    r[a] = :"#{a}#{suffix}"
  }
  self.rename(renaming)
end