Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
.gitignore
Gemfile
Gemfile.lock
README.md
Rakefile
ooor-finders.gemspec

README.md

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
Something went wrong with that request. Please try again.