Categories: None [Edit]
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: 49,364 of 183,052
Downloads: 20,449
Daily
Ranking: 53,223 of 183,043
Downloads: 1
Downloads Trends
Ranking Trends
Num of Versions Trends
Popular Versions (Major)
Popular Versions (Major.Minor)
Depended by
Rank | Downloads | Name |
---|
Owners
# | Gravatar | Handle |
---|---|---|
1 | jelf |