storext 0.1.4 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a63def211664fda8bf9e6551e1cdcf632ae0c557
4
- data.tar.gz: d270b2a34ffe9cf9969480bb23398b6fb5e35da6
3
+ metadata.gz: 1da3c0f4de333dec59e7b7c8821bc3f739ac3df8
4
+ data.tar.gz: 88b15eeb254370c4d2b640d6d627bb4ef1917aba
5
5
  SHA512:
6
- metadata.gz: 8b6af2eb762d8319ae340f7839ffb2a118f11dab52bf18438450358fe6f6b51c8c566b350673b8267f7333f76537de2e4f0c417965533bd45b9bca96103306bd
7
- data.tar.gz: 4df6dec32afed9fc67480894f23c3a4d8b8f8c269f7bce7eb0fac30203c7aa06134d59b29668520807e5d309d3f3cc30fc22243615c5e7b620fb3073cd73f8dd
6
+ metadata.gz: e2bda6c2e05d733fdeb02d657d75acbcea0f21f5b354460bc43bd4b78364fe6088d8423e02198f47d9ea4b81c8d380eb9f152fedb9e1f3ac28e38b85939c89c9
7
+ data.tar.gz: af708a1b323d18698655f97b9c7319db44f637b68366f904ca126ce63facc3326d536134284ea7cb27f95442296952014c88cfea67d0fd791141acf743cff860
data/lib/storext.rb CHANGED
@@ -6,11 +6,33 @@ require "storext/instance_methods"
6
6
 
7
7
  module Storext
8
8
 
9
+ def self.model(options={})
10
+ mod = Module.new do
11
+ mattr_accessor :storext_options
12
+
13
+ def self.included(base)
14
+ base.class_attribute :storext_options
15
+ base.storext_options = self.storext_options
16
+ base.send :include, Storext
17
+ end
18
+ end
19
+
20
+ mod.storext_options = options
21
+
22
+ mod
23
+ end
24
+
9
25
  extend ActiveSupport::Concern
10
26
 
11
27
  included do
12
28
  include InstanceMethods
13
29
 
30
+ unless respond_to?(:storext_options)
31
+ warn "Storext must be included via `include Storext.model` instead. Not specifying `.model` has been deprecated. (included from #{self.to_s})"
32
+ class_attribute :storext_options
33
+ self.storext_options = {}
34
+ end
35
+
14
36
  class_attribute :store_attribute_defs
15
37
  self.store_attribute_defs = {}
16
38
 
@@ -19,6 +41,12 @@ module Storext
19
41
  end
20
42
 
21
43
  after_initialize :set_storext_defaults
44
+
45
+ self.storext_options.each do |column, default|
46
+ self.send :define_method, column do
47
+ self.read_attribute(column) || default
48
+ end
49
+ end
22
50
  end
23
51
 
24
52
  end
@@ -1,3 +1,3 @@
1
1
  module Storext
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - G5
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-13 00:00:00.000000000 Z
13
+ date: 2015-01-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails