homeschool 0.0.1.27 → 0.0.1.31
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/form_buildr.rb +1 -1
- data/lib/homeschool.rb +5 -0
- data/lib/model_extensions.rb +14 -0
- data/lib/tame_rails.rb +1 -0
- data/test/module_tests.rb +26 -0
- metadata +5 -3
data/lib/form_buildr.rb
CHANGED
@@ -61,6 +61,6 @@ class ActionView::Helpers::FormBuilder
|
|
61
61
|
|
62
62
|
def label_for(method, options={})
|
63
63
|
options = {:label => options} if options.is_a? String
|
64
|
-
%{<label class="fieldLabel" for="#{options[:id] || "#{@object_name}_#{method}"}">#{options[:label] || method
|
64
|
+
%{<label class="fieldLabel" for="#{options[:id] || "#{@object_name}_#{method}"}">#{options[:label] || @object.human_name(method)}#{":" if !options[:no_colon]}</label>}
|
65
65
|
end
|
66
66
|
end
|
data/lib/homeschool.rb
CHANGED
@@ -82,6 +82,11 @@ class Module
|
|
82
82
|
end
|
83
83
|
alias_method :append_features_without_pattern_methods, :append_features
|
84
84
|
alias_method :append_features, :append_features_with_pattern_methods
|
85
|
+
|
86
|
+
def add_extension(extension)
|
87
|
+
self.extend extension::ClassMethods
|
88
|
+
self.send(:include, extension::InstanceMethods)
|
89
|
+
end
|
85
90
|
end
|
86
91
|
|
87
92
|
module Enumerable
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Homeschool; module ModelExtensions
|
2
|
+
module ClassMethods
|
3
|
+
def human_field_names(hash=nil)
|
4
|
+
@human_field_names = hash if hash
|
5
|
+
@human_field_names || {}
|
6
|
+
end
|
7
|
+
end
|
8
|
+
module InstanceMethods
|
9
|
+
def human_name(field)
|
10
|
+
self.class.human_field_names[field.to_sym] || field.to_s.titleize
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end; end
|
14
|
+
ActiveRecord::Base.add_extension(Homeschool::ModelExtensions)
|
data/lib/tame_rails.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + "/../lib/homeschool"
|
3
|
+
|
4
|
+
class ModuleTests < Test::Unit::TestCase
|
5
|
+
def test_add_extension
|
6
|
+
assert !MyTestClass.methods.include?(:my_class_method)
|
7
|
+
assert !MyTestClass.new.respond_to?(:my_instance_method)
|
8
|
+
MyTestClass.add_extension(MyTestModule)
|
9
|
+
assert MyTestClass.methods.include?('my_class_method')
|
10
|
+
assert MyTestClass.new.respond_to?(:my_instance_method)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class MyTestClass
|
15
|
+
end
|
16
|
+
|
17
|
+
module MyTestModule
|
18
|
+
module ClassMethods
|
19
|
+
def my_class_method
|
20
|
+
end
|
21
|
+
end
|
22
|
+
module InstanceMethods
|
23
|
+
def my_instance_method
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: homeschool
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.1.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.0.1.31
|
7
|
+
date: 2007-10-05 00:00:00 -04:00
|
8
8
|
summary: The homeschool gem
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -36,10 +36,12 @@ files:
|
|
36
36
|
- bin/gfight
|
37
37
|
- bin/homeschool
|
38
38
|
- bin/svm
|
39
|
+
- test/module_tests.rb
|
39
40
|
- test/the_test.rb
|
40
41
|
- lib/fight.rb
|
41
42
|
- lib/form_buildr.rb
|
42
43
|
- lib/homeschool.rb
|
44
|
+
- lib/model_extensions.rb
|
43
45
|
- lib/standardized_test.rb
|
44
46
|
- lib/tame_rails.rb
|
45
47
|
test_files: []
|