virtual_attribute 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Philip Roberts
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/README.md ADDED
File without changes
data/ROADMAP.md ADDED
File without changes
@@ -0,0 +1,3 @@
1
+ module VirtualAttribute
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,31 @@
1
+ class Module
2
+ def virtual_attribute( name, options={} )
3
+ name_equals = "#{name.to_s}="
4
+ inst_var = "@#{name.to_s}"
5
+ module_eval do
6
+
7
+ if options[:boolean]
8
+ define_method(name_equals) do |val|
9
+ val = val.to_s.strip
10
+ if ['1', 'true', 'yes'].include?(val)
11
+ instance_variable_set(inst_var, true)
12
+ elsif ['0', 'false', 'no'].include?(val)
13
+ instance_variable_set(inst_var, false)
14
+ end
15
+ end
16
+ else
17
+ define_method(name_equals) do |val|
18
+ instance_variable_set(inst_var, val)
19
+ end
20
+ end
21
+
22
+ define_method(name) do
23
+ instance_variable_get(inst_var)
24
+ end
25
+
26
+ if options[:attr_type] && self.respond_to?(options[:attr_type])
27
+ self.send(options[:attr_type], name)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1 @@
1
+ require 'virtual_attribute/virtual_attribute'
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: virtual_attribute
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Philip Roberts
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-08-09 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: You're definitely going to want to replace a lot of this
22
+ email:
23
+ - phil@floatapp.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - lib/virtual_attribute/version.rb
32
+ - lib/virtual_attribute/virtual_attribute.rb
33
+ - lib/virtual_attribute.rb
34
+ - LICENSE
35
+ - CHANGELOG.md
36
+ - README.md
37
+ - ROADMAP.md
38
+ has_rdoc: true
39
+ homepage: http://github.com/latentflip/virtual_attribute
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options: []
44
+
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 1
60
+ - 3
61
+ - 6
62
+ version: 1.3.6
63
+ requirements: []
64
+
65
+ rubyforge_project: virtual_attribute
66
+ rubygems_version: 1.3.6
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: A new gem templates
70
+ test_files: []
71
+