<commit_before>= duck_chain

== Intro
This gem's purpose is to generate basic chainable search methods on models in Rails 3 similar to searchlogic's dynamic named scopes.

duck_chain's original purpose is to help with the transition from Rails 2 to 3. A lot of projects use searchlogic, and while metasearch
is a fine replacement, it doesn't provide the dynamic named scopes (ie Post.title_equals("foobar").content_like("I like pie"). To help with the
transition, duck_chain extends ActiveRecord and creates extra chainable model methods for attributes you specifiy which act similar to the basic
searchlogic named scopes. The methods simply return Arel where cluases so you can chain them with other methods.

Only the basic single table methods are supported (eq, not_equal, gte, like, etc.). Meaning you can't do Post.post_comments_title_eq("This blog sux"). 
Legacy code like that should be converted into an Arel where method, metasearch search method, or whatever you decide to go with for Rails 3. Again,
the gem was built to help with the transition and provide some of the basic search methods people using searchlogic are used to in Rails 3. Plus, I personally like typing out
Post.created_at_gte(Time.now).content_like("I like shorts. They're comfortable and easy to wear.") more than Post.where(['created_at >= ?', Time.now]).where("content LIKE '%I like shorts. They're comfortable and easy to wear.%'").
Just seems a little clearer this way. :)

== Setup
Include the gem in your GemFile like any other gem.

== Usage
Consider the following model...
  class Post < ActiveRecord::Base
    # Fields:
    #   id:integer
    #   title:string
    #   content:text
    #   url:string
    #   comment_counter:integer
    #   created_at:datetime
    #   updated_at:datetime
  end

==== Use all search methods for selected attributes
To have duck_chain bind to the title, content, and url attributes of the model...
  class Post < ActiveRecord::Base
    duck_chain :content, 'title', :url
    # Note you can use symbols or strings in your list of attributes
  end

Calling duck_chain creates a bunch of chainable methods for the Post model for the content, title, and url attributes...

Example new methods related to the title attribute:

<i>The following <b>'eq'</b> methods can accept a string, array, or range</i>
* title_eq
* title_equals
* title_is
* title_in
* title_neq
* title_not_equal
* title_is_not<commit_msg>updating the readme for the new duck_chain_all method<commit_after>= duck_chain

== Intro
This gem's purpose is to generate basic chainable search methods on models in Rails 3 similar to searchlogic's dynamic named scopes.

duck_chain's original purpose is to help with the transition from Rails 2 to 3. A lot of projects use searchlogic, and while metasearch
is a fine replacement, it doesn't provide the dynamic named scopes (ie Post.title_equals("foobar").content_like("I like pie"). To help with the
transition, duck_chain extends ActiveRecord and creates extra chainable model methods for attributes you specifiy which act similar to the basic
searchlogic named scopes. The methods simply return Arel where cluases so you can chain them with other methods.

Only the basic single table methods are supported (eq, not_equal, gte, like, etc.). Meaning you can't do Post.post_comments_title_eq("This blog sux").
Legacy code like that should be converted into an Arel where method, metasearch search method, or whatever you decide to go with for Rails 3. Again,
the gem was built to help with the transition and provide some of the basic search methods people using searchlogic are used to in Rails 3. Plus, I personally like typing out
Post.created_at_gte(Time.now).content_like("I like shorts. They're comfortable and easy to wear.") more than Post.where(['created_at >= ?', Time.now]).where("content LIKE '%I like shorts. They're comfortable and easy to wear.%'").
Just seems a little clearer this way. :)

== Setup
Include the gem in your GemFile like any other gem.

== Usage
Consider the following model...
  class Post < ActiveRecord::Base
    # Fields:
    #   id:integer
    #   title:string
    #   content:text
    #   url:string
    #   comment_counter:integer
    #   created_at:datetime
    #   updated_at:datetime
  end

==== Use all search methods for selected attributes
To have duck_chain bind to the title, content, and url attributes of the model...
  class Post < ActiveRecord::Base
    duck_chain :content, 'title', :url
    # Note you can use symbols or strings in your list of attributes
  end

Calling duck_chain creates a bunch of chainable methods for the Post model for the content, title, and url attributes

Or, instead of specifying exactly which attributes to chain, you can call
  class Post < ActiveRecord::Base
    duck_chain_all
  end
which will add duck_chain to all of the attributes of the model
...

Example new methods related to the title attribute:

<i>The following <b>'eq'</b> methods can accept a string, array, or range</i>
* title_eq
* title_equals
* title_is
* title_in
* title_neq
* title_not_equal
* title_is_not
{'fraction_non_alphanumeric': 0.0650294695481336, 'fraction_numerical': 0.0019646365422396855, 'mean_word_length': 4.275647668393782, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6455004', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1338, 'n_words': 687}