active_pstore 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ebab73c6f6546e1154c1378f6033395789ea405
4
- data.tar.gz: a57ed34a2b0ea37fae184081a0da68d7835fc2d1
3
+ metadata.gz: ada1788e4287ebb96273bb3ccf4b608cd1715c2c
4
+ data.tar.gz: da5871ed491c62b51d8f4fc7c3d03c4cd824c3be
5
5
  SHA512:
6
- metadata.gz: 726de17ef5ea0b416c0da6c39801e1a954de39b523e9dd3d7ad5dba2f85e07c47fa7d409897f12ccfd23862fd73b138ecc7003451b5a46bdc485652d605de504
7
- data.tar.gz: ddb7aca9f701696d90942b74f5e377345cbfda23a1f21b15c5394f8530a2d6732d2d56de028cccea3a0847d769efd4cbce11f1dcc4b59d5e19764585561b9f36
6
+ metadata.gz: 3d30a366b3b61951ba694878e96644c3f527e6bd5a06743618f2a1b77ab8b78787a99f3740a59711417d8f521771e6d170ed7082fe70f1af559be4f065f5e1c6
7
+ data.tar.gz: 5f29c26e6d57333b096c103d85a7a9f61f65b04d8625732234b388d25e1227c1df450f05d557ac2db04c02709c0071d27d875cb757c81ce0e3eb464d32c43460
data/README.ja.md CHANGED
@@ -19,14 +19,10 @@
19
19
  require 'active_pstore'
20
20
 
21
21
  class Artist < ActivePStore::Base
22
- def initialize(name)
23
- @name = name
24
- end
25
-
26
- attr_reader :name
22
+ attr_accessor :name
27
23
  end
28
24
 
29
- randy_rhoads = Artist.new('Randy Rhoads')
25
+ randy_rhoads = Artist.new(name: 'Randy Rhoads')
30
26
  ```
31
27
 
32
28
  ### データの保存先のファイルパス指定
data/README.md CHANGED
@@ -18,14 +18,10 @@ This library has [Active Record](https://github.com/rails/rails/tree/master/acti
18
18
  require 'active_pstore'
19
19
 
20
20
  class Artist < ActivePStore::Base
21
- def initialize(name)
22
- @name = name
23
- end
24
-
25
- attr_reader :name
21
+ attr_accessor :name
26
22
  end
27
23
 
28
- randy_rhoads = Artist.new('Randy Rhoads')
24
+ randy_rhoads = Artist.new(name: 'Randy Rhoads')
29
25
  ```
30
26
 
31
27
  ### specify data store path
@@ -1,26 +1,33 @@
1
- require 'forwardable'
2
-
3
1
  module ActivePStore
4
2
  class Base
5
3
  extend ActivePStore::ConnectionHandling
6
4
  extend ActivePStore::DynamicMatchers
7
5
  extend ActivePStore::FinderMethods
8
6
  extend ActivePStore::Inheritance
9
- extend ActivePStore::Querying
10
- extend ActivePStore::QueryMethods
11
7
  extend ActivePStore::ModelSchema
8
+ extend ActivePStore::QueryMethods
9
+ extend ActivePStore::Querying
10
+ extend ActivePStore::Delegation
12
11
  include ActivePStore::Core
13
12
  include ActivePStore::Persistence
14
13
 
15
- extend SingleForwardable
16
-
17
- def_delegators :all, :ids, :count, :minimum, :maximum
14
+ def initialize(attributes = {})
15
+ attributes.each do |attr, val|
16
+ if respond_to? "#{attr}=".to_sym
17
+ self.__send__("#{attr}=", val)
18
+ else
19
+ raise "Unknown method, '#{attr}='"
20
+ end
21
+ end
22
+ end
18
23
 
19
24
  class << self
25
+ alias build new
26
+
20
27
  def all
21
- use_connection do |connection|
28
+ use_connection {|connection|
22
29
  ActivePStore::Collection.new(connection[self.pstore_key] || [])
23
- end
30
+ }
24
31
  end
25
32
  end
26
33
  end
@@ -0,0 +1,9 @@
1
+ require 'forwardable'
2
+
3
+ module ActivePStore
4
+ module Delegation
5
+ extend Forwardable
6
+
7
+ def_delegators :all, :ids, :count, :minimum, :maximum
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module ActivePStore
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.7'
3
3
  end
data/lib/active_pstore.rb CHANGED
@@ -4,6 +4,7 @@ require 'active_pstore/calculations'
4
4
  require 'active_pstore/collection'
5
5
  require 'active_pstore/connection_handling'
6
6
  require 'active_pstore/core'
7
+ require 'active_pstore/delegation'
7
8
  require 'active_pstore/dynamic_matchers'
8
9
  require 'active_pstore/finder_methods'
9
10
  require 'active_pstore/inheritance'
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.6
4
+ version: 0.4.7
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-16 00:00:00.000000000 Z
11
+ date: 2015-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter
@@ -53,6 +53,7 @@ files:
53
53
  - lib/active_pstore/collection.rb
54
54
  - lib/active_pstore/connection_handling.rb
55
55
  - lib/active_pstore/core.rb
56
+ - lib/active_pstore/delegation.rb
56
57
  - lib/active_pstore/dynamic_matchers.rb
57
58
  - lib/active_pstore/errors.rb
58
59
  - lib/active_pstore/finder_methods.rb
@@ -61,7 +62,6 @@ files:
61
62
  - lib/active_pstore/persistence.rb
62
63
  - lib/active_pstore/query_methods.rb
63
64
  - lib/active_pstore/querying.rb
64
- - lib/active_pstore/timestamps.rb
65
65
  - lib/active_pstore/version.rb
66
66
  homepage: http://github.com/koic/active_pstore
67
67
  licenses:
@@ -1,14 +0,0 @@
1
- module ActivePStore
2
- module Timestamps
3
- module Created
4
- attr_accessor :created_at
5
- end
6
-
7
- module Updated
8
- attr_accessor :updated_at
9
- end
10
-
11
- include Created
12
- include Updated
13
- end
14
- end