associate_by 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest ADDED
@@ -0,0 +1,5 @@
1
+ Manifest
2
+ README.markdown
3
+ Rakefile
4
+ init.rb
5
+ lib/associate_by.rb
data/README.markdown ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('associate_by', '0.0.1') do |p|
6
+ p.description = "Associate objects using a specific attribute"
7
+ p.url = "http://github.com/crowdint/associate_by"
8
+ p.author = "David Padilla"
9
+ p.email = "david@crowdint.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*"]
11
+ p.development_dependencies = []
12
+ end
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{associate_by}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["David Padilla"]
9
+ s.date = %q{2010-07-13}
10
+ s.description = %q{Associate objects using a specific attribute}
11
+ s.email = %q{david@crowdint.com}
12
+ s.extra_rdoc_files = ["README.markdown", "lib/associate_by.rb"]
13
+ s.files = ["Manifest", "README.markdown", "Rakefile", "init.rb", "lib/associate_by.rb", "associate_by.gemspec"]
14
+ s.homepage = %q{http://github.com/crowdint/associate_by}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Associate_by", "--main", "README.markdown"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{associate_by}
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.summary = %q{Associate objects using a specific attribute}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'associate_by'
@@ -0,0 +1,24 @@
1
+ module AssociateBy
2
+ def self.included(base)
3
+ base.extend(ClassMethods)
4
+ end
5
+
6
+ module ClassMethods
7
+ def associate_by(association, method)
8
+ define_method("#{association.to_s.singularize}_#{method}") do
9
+ ""
10
+ end
11
+
12
+ define_method("#{association.to_s.singularize}_#{method}=") do |value|
13
+ object = association.to_s.singularize.camelize.constantize.where(["#{method} = ?", value]) unless value.nil?
14
+ if object
15
+ send(association) << object
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ class ActiveRecord::Base
23
+ include AssociateBy
24
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: associate_by
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - David Padilla
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-13 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Associate objects using a specific attribute
23
+ email: david@crowdint.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.markdown
30
+ - lib/associate_by.rb
31
+ files:
32
+ - Manifest
33
+ - README.markdown
34
+ - Rakefile
35
+ - init.rb
36
+ - lib/associate_by.rb
37
+ - associate_by.gemspec
38
+ has_rdoc: true
39
+ homepage: http://github.com/crowdint/associate_by
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --line-numbers
45
+ - --inline-source
46
+ - --title
47
+ - Associate_by
48
+ - --main
49
+ - README.markdown
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 11
67
+ segments:
68
+ - 1
69
+ - 2
70
+ version: "1.2"
71
+ requirements: []
72
+
73
+ rubyforge_project: associate_by
74
+ rubygems_version: 1.3.7
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Associate objects using a specific attribute
78
+ test_files: []
79
+