shadow_model 0.1.1 → 0.1.2

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: e3c9efb64ff1507c2a3bb52cfdb0f3cb5170cc11
4
- data.tar.gz: eac4e8e566f6b430673ca18eaa331884e79558b4
3
+ metadata.gz: 9518b18405e37c61c19150b09c2c4203592b6584
4
+ data.tar.gz: cb61c047872eb147c663f91f17a2e4879e4370b7
5
5
  SHA512:
6
- metadata.gz: ec6a1e6e66cdc55c9968882310e01884d70ab59c2e5072cbc4146431636b0661aeaf1762f5ea6dd13839f118c6dc9dae9edf957ccd037fdf8e8d7f6be4c30f73
7
- data.tar.gz: 05815242f6983486b71d5a1b98b9f24c491f9242540d1dcefb6d0f4d4eb94e6424c31462c4b94dcca32f1a8ee8331b7b2700fea4ed9d794bbaf2089e45372d7f
6
+ metadata.gz: dc810d648888fc744c8fc6f781e6fad8adb0102e19d89e2e9648a942c4d6cc1247f659b186360795446644782d2d55940a58f5acc16f675665a4efe16f76908e
7
+ data.tar.gz: fd22eef1713aef85f2d4f7d1fc31aea29bc50c25f33feebab4e1d91ecf8bffc4269ea2eb70c95ed6613c3f1174a9b9de6a88812c7479431e44f8ea70df3bbea2
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A rails plugin use redis to cache models data.
4
4
 
5
- [![Build Status](https://travis-ci.org/cctiger36/shadow_model.png?branch=master)](https://travis-ci.org/cctiger36/shadow_model) [![Gem Version](https://badge.fury.io/rb/shadow_model.png)](http://badge.fury.io/rb/shadow_model) [![Coverage Status](https://coveralls.io/repos/cctiger36/shadow_model/badge.png)](https://coveralls.io/r/cctiger36/shadow_model) [![Code Climate](https://codeclimate.com/github/cctiger36/shadow_model.png)](https://codeclimate.com/github/cctiger36/shadow_model)
5
+ [![Build Status](https://travis-ci.org/cctiger36/shadow_model.png?branch=master)](https://travis-ci.org/cctiger36/shadow_model) [![Gem Version](https://badge.fury.io/rb/shadow_model.png)](http://badge.fury.io/rb/shadow_model) [![Coverage Status](https://coveralls.io/repos/cctiger36/shadow_model/badge.png)](https://coveralls.io/r/cctiger36/shadow_model) [![Code Climate](https://codeclimate.com/github/cctiger36/shadow_model.png)](https://codeclimate.com/github/cctiger36/shadow_model) [![Dependency Status](https://gemnasium.com/cctiger36/shadow_model.png)](https://gemnasium.com/cctiger36/shadow_model)
6
6
 
7
7
  ## Installation
8
8
 
@@ -1,5 +1,5 @@
1
1
  module ShadowModel
2
- module Extension
2
+ module ModelExtension
3
3
  def self.included(base)
4
4
  base.class_eval <<-RUBY
5
5
  mattr_accessor :shadow_options
@@ -26,6 +26,12 @@ module ShadowModel
26
26
 
27
27
  def shadow_data=(data)
28
28
  @shadow_data = data
29
+ self.class.attribute_names.each do |attribute_name|
30
+ attribute_name = attribute_name.to_sym
31
+ if value = data[attribute_name]
32
+ self[attribute_name] = value
33
+ end
34
+ end
29
35
  end
30
36
 
31
37
  def clear_shadow_data
@@ -1,3 +1,3 @@
1
1
  module ShadowModel
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/shadow_model.rb CHANGED
@@ -5,12 +5,12 @@ require 'shadow_model/version'
5
5
  module ShadowModel
6
6
  extend ActiveSupport::Concern
7
7
 
8
- autoload :Extension, 'shadow_model/extension'
8
+ autoload :ModelExtension, 'shadow_model/model_extension'
9
9
 
10
10
  module ClassMethods
11
11
  def shadow_model(*args)
12
12
  options = args.last.is_a?(Hash) ? args.pop : {}
13
- self.send :include, ShadowModel::Extension
13
+ self.send :include, ShadowModel::ModelExtension
14
14
  set_shadow_keys(args, options)
15
15
  end
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shadow_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weihu Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-24 00:00:00.000000000 Z
11
+ date: 2013-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -87,7 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - lib/shadow_model/extension.rb
90
+ - lib/shadow_model/model_extension.rb
91
91
  - lib/shadow_model/version.rb
92
92
  - lib/shadow_model.rb
93
93
  - MIT-LICENSE