railhead_lazy_columns 0.0.1

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.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 [name of plugin creator]
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.
@@ -0,0 +1,7 @@
1
+ = RailheadLazyColumns
2
+
3
+ RailheadLazyColumns is a Ruby on Rails gem that lets load columns lazy.
4
+
5
+ == License
6
+
7
+ Copyright (c) 2012 Bence Nagy (nagybence@tipogral.hu), released under the MIT license.
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'railhead_lazy_columns'
@@ -0,0 +1,29 @@
1
+ require 'active_support'
2
+
3
+
4
+ module RailheadLazyColumns
5
+
6
+ def self.included(base)
7
+ base.extend ClassMethods
8
+ end
9
+
10
+ module ClassMethods
11
+
12
+ def lazy_columns(*keys)
13
+ keys.map! { |key| key.to_s }
14
+ class_eval { default_scope { select((column_names - keys).join(', ')) } }
15
+ keys.each do |key|
16
+ define_method key do
17
+ write_attribute(key, connection.select_value("SELECT #{connection.quote_column_name(key)} FROM #{self.class.quoted_table_name} WHERE #{self.class.primary_key} = #{quoted_id}")) unless has_attribute?(key)
18
+ read_attribute(key)
19
+ end
20
+ define_method "#{key}?" do
21
+ !!send(key)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+
29
+ ActiveRecord::Base.send :include, RailheadLazyColumns
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "railhead_lazy_columns"
3
+ s.version = "0.0.1"
4
+ s.date = "2012-04-27"
5
+ s.summary = "RailheadLazyColumns lets load columns lazy"
6
+ s.email = "nagybence@tipogral.hu"
7
+ s.homepage = "http://github.com/nagybence/railhead_lazy_columns"
8
+ s.description = "RailheadLazyColumns lets load columns lazy"
9
+ s.has_rdoc = true
10
+ s.authors = ["Bence Nagy"]
11
+ s.files = ["MIT-LICENSE",
12
+ "README.rdoc",
13
+ "init.rb",
14
+ "railhead_lazy_columns.gemspec",
15
+ "lib/railhead_lazy_columns.rb"]
16
+ s.rdoc_options = ["--main", "README.rdoc"]
17
+ s.extra_rdoc_files = ["README.rdoc"]
18
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: railhead_lazy_columns
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bence Nagy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-27 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: RailheadLazyColumns lets load columns lazy
15
+ email: nagybence@tipogral.hu
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files:
19
+ - README.rdoc
20
+ files:
21
+ - MIT-LICENSE
22
+ - README.rdoc
23
+ - init.rb
24
+ - railhead_lazy_columns.gemspec
25
+ - lib/railhead_lazy_columns.rb
26
+ homepage: http://github.com/nagybence/railhead_lazy_columns
27
+ licenses: []
28
+ post_install_message:
29
+ rdoc_options:
30
+ - --main
31
+ - README.rdoc
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 1.8.22
49
+ signing_key:
50
+ specification_version: 3
51
+ summary: RailheadLazyColumns lets load columns lazy
52
+ test_files: []