Categories: None [Edit]

xquery

https://rubygems.org/gems/xquery
https://github.com/JelF/xquery
# XQuery [![Join the chat at https://gitter.im/JelF/xquery](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/JelF/xquery?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/JelF/xquery.svg?branch=master)](https://travis-ci.org/JelF/xquery) [![Code Climate](https://codeclimate.com/github/JelF/xquery/badges/gpa.svg)](https://codeclimate.com/github/JelF/xquery) [![Test Coverage](https://codeclimate.com/github/JelF/xquery/badges/coverage.svg)](https://codeclimate.com/github/JelF/xquery/coverage) [![Issue Count](https://codeclimate.com/github/JelF/xquery/badges/issue_count.svg)](https://codeclimate.com/github/JelF/xquery) XQuery is designed to replace boring method call chains and allow to easier convert it in a builder classes ## Usage of `XQuery` function `XQuery` is a shortcat to `XQuery::Generic.with` ``` r = XQuery(''.html_safe) do |q| # similar to tap q << 'bla bla bla' q << 'bla bla bla' # using truncate q.truncate(15) # real content (q.send(:query)) mutated q << '!' end r # => "bla bla blab...!" ``` ## Usage of `XQuery::Abstract` I designed this gem to help me with `ActiveRecord` Queries, so i inherited `XQuery::Abstract` and used it's powers. It provides the following features ### `wrap_method` and `wrap_methods` when you call each of this methods they became automatically wrapped (`XQuery::Abstract` basically wraps all methods query `#respond_to?`) It means, that there are instance methods with same name defined and will change a `#query` to their call result. ``` self.query = query.foo(x) # is basically the same as foo(x) # when `wrap_method :foo` called ``` You can also specify new name using `wrap_method :foo, as: :bar` syntax ### `q` object `q` is a proxy object which holds all of wrapped methods, but not methods you defined inside your class. E.g. i have defined `wrap_method(:foo)`, but also delegated `#foo` to some another object. If i call `q.foo`, i will get wrapped method. No...

Total

Ranking: 48,782 of 180,702
Downloads: 19,898

Daily

Ranking: 43,761 of 180,689
Downloads: 8

Depended by

RankDownloadsName

Depends on

RankDownloadsName
12,107,069,537bundler
7900,314,781activesupport
16863,261,344rake
24772,716,171rspec
64426,812,400pry
68420,205,956rubocop
165196,924,771launchy
223143,611,496yard
1,62313,384,936coveralls

Owners

#GravatarHandle
1iconjelf