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 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.to_s.humanize}#{":" if !options[:no_colon]}</label>}
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
@@ -1,4 +1,5 @@
1
1
  require 'form_buildr'
2
+ require 'model_extensions'
2
3
 
3
4
  # Add find_object, model_name
4
5
  class ActionController::Base
@@ -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.0
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.27
7
- date: 2007-09-24 00:00:00 -04:00
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: []