0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Add Active Record like dynamic finder pattern
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0

Runtime

>= 1.6.5
 Project Readme

============ OOOR Finders

!!!!

This repository deprecated and not maintained by Camptocamp anymore. If you are interested in becoming the new maintainer just send a notification to camptocamp account

!!!

Following behaviors are added

  • find_by_XX
  • find_first_by_XX
  • find_all_by_XX
  • find_last_by_XX
  • find_or_create_by
  • find_or_initialize_by
  • find_by_xml_id or alias find_by_oid

So we can do:

require "ooor/finders"

ResUsers.find_by_xml_id('module.xml_id').id
ResUsers.find_by_id(23).id
ResUsers.find_by_name('Administrator').id
ResUsers.find_by_name!('Administrator').id # Will throw an exception if you put a ! at the end and nothing is found

We can also use all or last:

ResUsers.find_all_by_name('Administrator')
ResUsers.find_last_by_name('Administrator')
ResUsers.find_last_by_name_and_login('Administrator', 'admin')
ResUsers.find_by_name_and_login('Administrator', 'admin')

Plus the create mode:

ResUsers.find_or_create_by_login_and_name_and_oid 'toto', 'toto', 'base.toto'
ResUsers.find_or_create_by_login_and_name'toto', 'toto'

Other options are supported:

ResUsers.find_all_by_name('Administrator', :fields=>['id'], :limit=>20)

Installation


gem install ooor-finders