active_pstore 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.ja.md +6 -0
- data/README.md +8 -2
- data/lib/active_pstore.rb +1 -0
- data/lib/active_pstore/base.rb +7 -16
- data/lib/active_pstore/collection.rb +6 -2
- data/lib/active_pstore/model_schema.rb +9 -0
- data/lib/active_pstore/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ebab73c6f6546e1154c1378f6033395789ea405
|
4
|
+
data.tar.gz: a57ed34a2b0ea37fae184081a0da68d7835fc2d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 726de17ef5ea0b416c0da6c39801e1a954de39b523e9dd3d7ad5dba2f85e07c47fa7d409897f12ccfd23862fd73b138ecc7003451b5a46bdc485652d605de504
|
7
|
+
data.tar.gz: ddb7aca9f701696d90942b74f5e377345cbfda23a1f21b15c5394f8530a2d6732d2d56de028cccea3a0847d769efd4cbce11f1dcc4b59d5e19764585561b9f36
|
data/README.ja.md
CHANGED
@@ -43,6 +43,12 @@ randy_rhoads.save
|
|
43
43
|
|
44
44
|
saveメソッドの対象オブジェクトのクラス名がPStoreのキーになります。
|
45
45
|
|
46
|
+
```ruby
|
47
|
+
Artist.table_name # => 'Artist'
|
48
|
+
```
|
49
|
+
|
50
|
+
例えばPStoreをもちいて保存されたartistオブジェクトを取得してみます。
|
51
|
+
|
46
52
|
```ruby
|
47
53
|
database = PStore.new('/path/to/file')
|
48
54
|
database.transaction {|db| artist = db['Artist'] } # fetch instances of Artist class.
|
data/README.md
CHANGED
@@ -42,6 +42,12 @@ randy_rhoads.save
|
|
42
42
|
|
43
43
|
database key is string of class name.
|
44
44
|
|
45
|
+
```ruby
|
46
|
+
Artist.table_name # => 'Artist'
|
47
|
+
```
|
48
|
+
|
49
|
+
ex) Fetch stored artist objects by pure PStore.
|
50
|
+
|
45
51
|
```ruby
|
46
52
|
database = PStore.new('/path/to/file')
|
47
53
|
database.transaction {|db| artist = db['Artist'] } # fetch instances of Artist class.
|
@@ -50,9 +56,9 @@ database.transaction {|db| artist = db['Artist'] } # fetch instances of Artist c
|
|
50
56
|
allocate value of ActivePStore::Base#id using [SecureRandom.hex](http://ruby-doc.org/stdlib-2.2.0/libdoc/securerandom//rdoc/SecureRandom.html#method-c-hex).
|
51
57
|
|
52
58
|
```ruby
|
53
|
-
>
|
59
|
+
> randy_rhoads.id # => nil
|
54
60
|
> randy_rhoads.save
|
55
|
-
>
|
61
|
+
> randy_rhoads.id # => "0b84ece5d5be3bce3ee2101c1c4f6fda"
|
56
62
|
```
|
57
63
|
|
58
64
|
### find series
|
data/lib/active_pstore.rb
CHANGED
@@ -7,6 +7,7 @@ require 'active_pstore/core'
|
|
7
7
|
require 'active_pstore/dynamic_matchers'
|
8
8
|
require 'active_pstore/finder_methods'
|
9
9
|
require 'active_pstore/inheritance'
|
10
|
+
require 'active_pstore/model_schema'
|
10
11
|
require 'active_pstore/persistence'
|
11
12
|
require 'active_pstore/query_methods'
|
12
13
|
require 'active_pstore/querying'
|
data/lib/active_pstore/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
1
3
|
module ActivePStore
|
2
4
|
class Base
|
3
5
|
extend ActivePStore::ConnectionHandling
|
@@ -6,31 +8,20 @@ module ActivePStore
|
|
6
8
|
extend ActivePStore::Inheritance
|
7
9
|
extend ActivePStore::Querying
|
8
10
|
extend ActivePStore::QueryMethods
|
11
|
+
extend ActivePStore::ModelSchema
|
9
12
|
include ActivePStore::Core
|
10
13
|
include ActivePStore::Persistence
|
11
14
|
|
15
|
+
extend SingleForwardable
|
16
|
+
|
17
|
+
def_delegators :all, :ids, :count, :minimum, :maximum
|
18
|
+
|
12
19
|
class << self
|
13
20
|
def all
|
14
21
|
use_connection do |connection|
|
15
22
|
ActivePStore::Collection.new(connection[self.pstore_key] || [])
|
16
23
|
end
|
17
24
|
end
|
18
|
-
|
19
|
-
def ids
|
20
|
-
all.ids
|
21
|
-
end
|
22
|
-
|
23
|
-
def minimum(attr_name)
|
24
|
-
all.minimum(attr_name)
|
25
|
-
end
|
26
|
-
|
27
|
-
def maximum(attr_name)
|
28
|
-
all.maximum(attr_name)
|
29
|
-
end
|
30
|
-
|
31
|
-
def pstore_key
|
32
|
-
self.to_s
|
33
|
-
end
|
34
25
|
end
|
35
26
|
end
|
36
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_pstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi ITO
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codeclimate-test-reporter
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/active_pstore/errors.rb
|
58
58
|
- lib/active_pstore/finder_methods.rb
|
59
59
|
- lib/active_pstore/inheritance.rb
|
60
|
+
- lib/active_pstore/model_schema.rb
|
60
61
|
- lib/active_pstore/persistence.rb
|
61
62
|
- lib/active_pstore/query_methods.rb
|
62
63
|
- lib/active_pstore/querying.rb
|