storext-override 0.1.1 → 0.2.0

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: a4fe6aff50589d2c2f29211a4fb34683484b352d
4
- data.tar.gz: 3c551308234e3a6a5f4c2af102e317ce41e60e18
3
+ metadata.gz: 5c93086218e4ca329cb9a62bd6bf697103bd06f7
4
+ data.tar.gz: 30a40760d63e45e8b36b1605e4d297c9ac90a4d9
5
5
  SHA512:
6
- metadata.gz: d4838eb8596b6afd92da762ef50fcc74d3bb05fcc87e8d8035dae3e13e5f0a2f22bd9522c324e72736209e4d759d220777f98325a621b452704981f064051f38
7
- data.tar.gz: c6dd4852fd8b8ddde74193b2964c54bb4e0fc6939d9dd934ef19c2c90d6fb5f16c96260d358cc8b18de7be75fd6dea21365a0b7d1ded70ba8e73a7f45fa89526
6
+ metadata.gz: c5d6a41c869423a68741834136e2b1af63c28f5d30ca8713a8b19222db42a7127ea6d3ebb40fc25f2e564c472deb5882af1ad129c850a862eae62f3aeaf653e0
7
+ data.tar.gz: a8ce92acdf8f7d1689f1913f1aa243211e770793785bac7d2b59a0022349522a504a209b370c840e2362202769e79794960dde9ddf88b180b2d784d6cdeaae43
data/README.md CHANGED
@@ -24,6 +24,17 @@ class Phone < ActiveRecord::Base
24
24
 
25
25
  storext_override(:computer, :data)
26
26
  end
27
+
28
+ class SimCard < ActiveRecord::Base
29
+ store :data, coder: JSON
30
+
31
+ belongs_to :phone
32
+ include Storext::Override
33
+
34
+ # If you want to override :computer, but it's a not directly associated
35
+ delegate :computer, to: :phone
36
+ storext_override(:computer, :data, class: Komputer)
37
+ end
27
38
  ```
28
39
 
29
40
  This looks at Computer's `data` column and copies all accessors into its own, withe override ability.
@@ -10,12 +10,16 @@ module Storext
10
10
  end
11
11
 
12
12
  module ClassMethods
13
- def storext_override(association_name, column_name)
14
- association =
15
- storext_overrider_find_association(association_name)
16
- association_class = association.class_name.constantize
17
-
18
- storext_definitions = association_class.storext_definitions
13
+ def storext_override(association_name, column_name, opts = {})
14
+ origin_class = if opts[:class]
15
+ opts[:class]
16
+ else
17
+ association =
18
+ storext_overrider_find_association(association_name)
19
+ association.class_name.constantize
20
+ end
21
+
22
+ storext_definitions = origin_class.storext_definitions
19
23
  storext_definitions.each do |attr, attr_definition|
20
24
  if attr_definition[:column] == column_name
21
25
  storext_overrider_accessor(
@@ -1,5 +1,5 @@
1
1
  module Storext
2
2
  module Override
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storext-override
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
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-06-26 00:00:00.000000000 Z
13
+ date: 2015-08-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails