Sha256: 740e695ec31ef5e64375c92e56ebc4fdf8711f91509d0276c48ffbee45f02627

Contents?: true

Size: 866 Bytes

Versions: 9

Compression:

Stored size: 866 Bytes

Contents

module Bmg
  module Algebra
    module Shortcuts

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

      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

      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

    end # module Shortcuts
  end # module Algebra
end # module Bmg

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bmg-0.14.5 lib/bmg/algebra/shortcuts.rb
bmg-0.14.4 lib/bmg/algebra/shortcuts.rb
bmg-0.14.3 lib/bmg/algebra/shortcuts.rb
bmg-0.14.2 lib/bmg/algebra/shortcuts.rb
bmg-0.14.1 lib/bmg/algebra/shortcuts.rb
bmg-0.14.0 lib/bmg/algebra/shortcuts.rb
bmg-0.13.0 lib/bmg/algebra/shortcuts.rb
bmg-0.12.0 lib/bmg/algebra/shortcuts.rb
bmg-0.11.0 lib/bmg/algebra/shortcuts.rb