methodise 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.
- data/README +19 -0
- data/init.rb +1 -0
- data/lib/methodise.rb +8 -0
- metadata +57 -0
data/README
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Methodise
|
2
|
+
================
|
3
|
+
|
4
|
+
Rails gem/plugin that adds instance methods for methods belonging to belongs_to associations.
|
5
|
+
|
6
|
+
Example:
|
7
|
+
|
8
|
+
class Parent < ActiveRecord::Base
|
9
|
+
has_many :children, :class_name => 'Child', :foreign_key => :parent_id
|
10
|
+
end
|
11
|
+
|
12
|
+
class Child < ActiveRecord::Base
|
13
|
+
belongs_to :parent, :class_name => 'Parent', :foreign_key => :parent_id
|
14
|
+
methodise :parent => [:name, :description]
|
15
|
+
end
|
16
|
+
|
17
|
+
This will create the following instance methods for Child :parent_name and :parent_description.
|
18
|
+
|
19
|
+
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'methodise'
|
data/lib/methodise.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
class ActiveRecord::Base
|
2
|
+
class << self
|
3
|
+
def methodise associations_hash
|
4
|
+
associations_hash.each { |association, methods| Array.new(methods).compact.each { |mthd| define_method("#{association}_#{mthd}") { send(association).try(mthd) } } }
|
5
|
+
end
|
6
|
+
alias_method :methodize, :methodise
|
7
|
+
end
|
8
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: methodise
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Neill
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-01 00:00:00 +00:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Rails gem/plugin which adds quick access to parent model methods
|
17
|
+
email: alex@featureless.co.uk
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README
|
26
|
+
- init.rb
|
27
|
+
- lib/methodise.rb
|
28
|
+
has_rdoc: true
|
29
|
+
homepage: http://github.com/ajn/methodise
|
30
|
+
licenses: []
|
31
|
+
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: "0"
|
42
|
+
version:
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.3.5
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: Rails gem/plugin which adds quick access to parent model methods
|
56
|
+
test_files: []
|
57
|
+
|