active_store_accessor 0.1.0 → 0.1.1

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: 204a4d2653c210af6ecf37c728933d00412a0523
4
- data.tar.gz: d37a87d43c4d2ce8fe53b065ad3a9639ce651e60
3
+ metadata.gz: 4292ddb949e1408e098e6b011b793712fac73aab
4
+ data.tar.gz: be546cf4e8bfc20c9ac95b42adaff2e45de4c29e
5
5
  SHA512:
6
- metadata.gz: ef4651493e7063e99909b7d147a6cc3acbd0a34216c0ee6f653e72e4f5a8eeb6f48a6a3a21196dd639a08fbaa218284a6f81b2a38aa1ec65593b18365b8a0ecb
7
- data.tar.gz: e9d4a3132b22cffe3298d0e6ceddd163250ad376dfe41dd370e1a247a5ce19bbe36271f36bd1088da7479888a8a41f05f302d201c662fbd4c0f7a03f1b6831a1
6
+ metadata.gz: 5430d75c6d0b771b4221b60356c7388881da5233b57815d1381ab170bb874a18a7eed652bbb7d730870c6056a08a5d861d81807329b765fd99e8d13f3d2e1f70
7
+ data.tar.gz: ee4f46f15a41cc510c488ea0cbb8a75629315bad8b1550b976e6bcfba01d16a58ace185ed205031a98f6764eb0df06eed4f95ea05e71c2e2b9c7d797fdf7bb9e
data/.travis.yml CHANGED
@@ -6,4 +6,3 @@ rvm:
6
6
  - 1.9.3
7
7
  - 2.0.0
8
8
  - 2.1.2
9
- - jruby-19mode
data/Gemfile CHANGED
@@ -11,3 +11,4 @@ ar_version = case ar_version
11
11
  "~> 4.1.0"
12
12
  end
13
13
  gem "activerecord", ar_version
14
+ gem "sqlite3"
data/README.md CHANGED
@@ -1,6 +1,34 @@
1
1
  # ActiveStoreAccessor
2
2
 
3
- Get more from ActiveRecord::Store
3
+ [![Build Status](https://travis-ci.org/jalkoby/active_store_accessor.svg?branch=master)](https://travis-ci.org/jalkoby/active_store_accessor)
4
+ [![Gem Version](https://badge.fury.io/rb/active_store_accessor.svg)](http://badge.fury.io/rb/active_store_accessor)
5
+ [![Code Climate](https://codeclimate.com/github/jalkoby/active_store_accessor.png)](https://codeclimate.com/github/jalkoby/active_store_accessor)
6
+
7
+ With `active_store_accessor` you can have boolean, integer, float, time store attributes which would act like a regular schema columns.
8
+
9
+ ## Usage
10
+
11
+ After you add gem into Gemfile everything is done for you. Now you can declare your serialized properties in a next way:
12
+
13
+ ```ruby
14
+ class Profile < ActiveRecord::Base
15
+ # basic usage(where `info` is a store column)
16
+ active_store_accessor :info, age: :integer, birthday: :time
17
+
18
+ # with default values
19
+ active_store_accessor :info, score: { type: :float, default: 0.0 },
20
+ active: { type: :boolean, default: true }
21
+ end
22
+
23
+ profile = Profile.new
24
+ profile.age = "23"
25
+ profile.age # => 23
26
+ profile.birthday = Time.new(2014, 5, 31)
27
+ profile.birthday # => 2014-05-31 00:00:00
28
+ profile.score # => 0.0
29
+ profile.score = 4.5
30
+ profile.score # => 4.5
31
+ ```
4
32
 
5
33
  ## Installation
6
34
 
@@ -11,20 +39,10 @@ Add this line to your application's Gemfile:
11
39
  And then execute:
12
40
 
13
41
  $ bundle
42
+
43
+ ## Requirements & dependencies
14
44
 
15
- Or install it yourself as:
16
-
17
- $ gem install active_store_accessor
18
-
19
- ## Usage
20
-
21
- After you add gem into Gemfile everything is done for you. Now you can declare your serialized properties in a next way:
22
-
23
- # basic usage(where `info` is a store column)
24
- active_store_accessor :info, age: :integer, birthday: :time
25
-
26
- # with default values
27
- active_store_accessor :info, score: { type: :float, default: 0.0 }, active: { type: :boolean, default: true }
45
+ This library has been tested on ruby 1.9.3+ and activerecord 3.2+. Any other configurations might have potential issues. `active_store_accessor` doesn't have any external dependency(expect activerecord) and contains only one file with one module.
28
46
 
29
47
  ## Contributing
30
48
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "active_store_accessor"
7
- spec.version = "0.1.0"
7
+ spec.version = "0.1.1"
8
8
  spec.authors = ["Sergey Pchelincev"]
9
9
  spec.email = ["mail@sergeyp.me"]
10
10
  spec.summary = %q{Get more from ActiveRecord::Store}
@@ -10,6 +10,11 @@ module ActiveStoreAccessor
10
10
  attrs.each do |attr_name, options|
11
11
  options = { type: options.to_s } unless options.is_a?(Hash)
12
12
  type = options.fetch(:type) { raise ArgumentError, "please specify type of attribute" }.to_s
13
+
14
+ # time for activerecord is only a hours and minutes without date part
15
+ # but for most rubist and rails developer it should contains a date too
16
+ type = :datetime if type == :time
17
+
13
18
  args = [attr_name.to_s, options[:default], type]
14
19
  active_store_attributes[attr_name] = ActiveRecord::ConnectionAdapters::Column.new(*args)
15
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_store_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Pchelincev