ooor_finders 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +34 -15
- data/lib/open_object_resource.rb +2 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -1,32 +1,51 @@
|
|
1
|
-
|
1
|
+
============
|
2
|
+
OOOR Finders
|
3
|
+
============
|
2
4
|
|
3
|
-
|
4
|
-
find_first_by_XX
|
5
|
-
find_all_by_XX
|
6
|
-
find_last_by_XX
|
7
|
-
+
|
8
|
-
find_by_xml_id or alias find_by_oid
|
5
|
+
Following behaviors are added
|
9
6
|
|
10
|
-
|
7
|
+
* find_by_XX
|
8
|
+
* find_first_by_XX
|
9
|
+
* find_all_by_XX
|
10
|
+
* find_last_by_XX
|
11
|
+
* find_or_create_by
|
12
|
+
* find_or_initialize_by
|
13
|
+
* find_by_xml_id or alias find_by_oid
|
11
14
|
|
15
|
+
So we can do:
|
16
|
+
```ruby
|
12
17
|
require "ooor_finders"
|
13
|
-
|
14
18
|
ResUsers.find_by_xml_id('module.xml_id').id
|
15
19
|
ResUsers.find_by_id(23).id
|
16
20
|
ResUsers.find_by_name('Administrator').id
|
17
|
-
ResUsers.find_by_name!('Administrator').id Will throw an exception if you put a ! at the end
|
21
|
+
ResUsers.find_by_name!('Administrator').id Will throw an exception if you put a ! at the end and nothing is found
|
22
|
+
```
|
18
23
|
|
19
|
-
We can also
|
24
|
+
We can also use all or last:
|
25
|
+
|
26
|
+
```ruby
|
20
27
|
ResUsers.find_all_by_name('Administrator')
|
21
28
|
ResUsers.find_last_by_name('Administrator')
|
22
29
|
ResUsers.find_last_by_name_and_login('Administrator', 'admin')
|
23
30
|
ResUsers.find_by_name_and_login('Administrator', 'admin')
|
31
|
+
```
|
24
32
|
|
25
|
-
Plus the create mode
|
26
|
-
|
33
|
+
Plus the create mode:
|
34
|
+
|
35
|
+
```ruby
|
27
36
|
ResUsers.find_or_create_by_login_and_name_and_oid 'toto', 'toto', 'base.toto'
|
28
37
|
ResUsers.find_or_create_by_login_and_name'toto', 'toto'
|
38
|
+
```
|
39
|
+
|
40
|
+
Other options are supported:
|
29
41
|
|
30
|
-
|
42
|
+
```ruby
|
43
|
+
ResUsers.find_all_by_name('Administrator', :fields=>['id'], :limit=>20)
|
44
|
+
```
|
31
45
|
|
32
|
-
|
46
|
+
*************
|
47
|
+
Installation
|
48
|
+
*************
|
49
|
+
```
|
50
|
+
gem install ooor_finders
|
51
|
+
```
|
data/lib/open_object_resource.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ooor_finders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nicolas Bessi - Camptocamp
|