storext 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ddfbae9c3b4d88ee6edad8d1f4b0ee5c9e1d92fe
4
+ data.tar.gz: 11d1690c785b77c0f1cf31e41cca96574cc027c3
5
+ SHA512:
6
+ metadata.gz: cfacc2880ea27fff8dbf5c5e73fb8e7d45b82e4aea34bacb07567220864a1f92b42ab644ffd35da3d76d4ac0046da096f79c933f7424bff2914ea071de9293a0
7
+ data.tar.gz: 46822864bee4560205cf23822212784c30f251aa8b4622bd0e77640cf33e9916c06dccb2cfd46eb37bf5953bed5127e459d349d7488d2f0aa12120787f490aed
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Storext'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -0,0 +1,3 @@
1
+ module Storext
2
+ VERSION = "0.0.1"
3
+ end
data/lib/storext.rb ADDED
@@ -0,0 +1,64 @@
1
+ require "active_support/concern"
2
+ require "virtus"
3
+
4
+ module Storext
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ class_attribute :store_attribute_defs
10
+ self.store_attribute_defs = {}
11
+ end
12
+
13
+ private
14
+
15
+ def storext_proxy
16
+ return @storext_proxy if @storext_proxy
17
+ @storext_proxy ||= self.class.storext_proxy_class.new
18
+ end
19
+
20
+ module ClassMethods
21
+ def store_attribute(column, attr, type=nil, opts={})
22
+ store_attribute_defs[column] ||= []
23
+ store_attribute_defs[column] << attr
24
+
25
+ storext_proxy_class.attribute "_casted_#{attr}", type, opts
26
+
27
+ define_method "#{attr}=" do |value|
28
+ storext_proxy.send("_casted_#{attr}=", value)
29
+ write_store_attribute column, attr, storext_proxy.send("_casted_#{attr}")
30
+ end
31
+
32
+ define_method attr do
33
+ if store_val = read_store_attribute(column, attr)
34
+ storext_proxy.send("_casted_#{attr}=", store_val)
35
+ end
36
+ storext_proxy.send("_casted_#{attr}")
37
+ end
38
+
39
+ store_accessor column, *store_attribute_defs[column]
40
+ end
41
+
42
+ def store_attributes(column, &block)
43
+ storext_proxy_class.define_store_attributes self, column, &block
44
+ end
45
+
46
+ def storext_proxy_class
47
+ @storext_proxy_class ||= Class.new do
48
+ include Virtus.model
49
+
50
+ def self.define_store_attributes(source_class, column, &block)
51
+ @source_class = source_class
52
+ @column = column
53
+ instance_eval &block
54
+ end
55
+
56
+ def self.method_missing(method_name, *args, &block)
57
+ @source_class.store_attribute @column, method_name, *args
58
+ end
59
+ end
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :storext do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: storext
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - G5
8
+ - Ramon Tayag
9
+ - Marc Rendl Ignacio
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2014-11-26 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '4.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '4.0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: virtus
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: pg
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: rspec
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ description: Extends ActiveRecord::Store.store_accessor
72
+ email:
73
+ - lateam@getg5.com
74
+ - ramon.tayag@gmail.com
75
+ - marcrendlignacio@gmail.com
76
+ executables: []
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - MIT-LICENSE
81
+ - Rakefile
82
+ - lib/storext.rb
83
+ - lib/storext/version.rb
84
+ - lib/tasks/storext_tasks.rake
85
+ homepage: http://github.com/g5/storext
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.2.2
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Extends ActiveRecord::Store.store_accessor
109
+ test_files: []