midas-inactive_record 1.0.0 → 1.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/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.0.0 2009-06-24
2
+
3
+ * Add attr_human_name method.
4
+
5
+
1
6
  == 1.0.0 2009-04-03
2
7
 
3
8
  * Initial release
data/README.rdoc CHANGED
@@ -39,6 +39,15 @@ Create a model class:
39
39
  validates_presence_of :name, :begin_date, :end_date
40
40
  end
41
41
 
42
+ In things_controller.rb:
43
+
44
+ @thing = Thing.new( params[:thing] )
45
+
46
+ unless @thing.valid?
47
+ render :new
48
+ return
49
+ end
50
+
42
51
  Now you can use errors_for, etc in your forms.
43
52
 
44
53
 
@@ -0,0 +1,41 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{inactive_record}
5
+ s.version = "1.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["C. Jason Harrelson"]
9
+ s.date = %q{2009-06-24}
10
+ s.description = %q{InactiveRecord gives you many of the features you know and love from ActiveRecord without the need for a backing database table.}
11
+ s.email = ["cjharrelson@gmail.com"]
12
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
13
+ s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "inactive_record.gemspec", "lib/inactive_record.rb", "lib/inactive_record/base.rb", "script/console", "script/destroy", "script/generate", "spec/inactive_record/base_spec.rb", "spec/inactive_record_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/midas/inactive_record/tree/master}
16
+ s.post_install_message = %q{PostInstall.txt}
17
+ s.rdoc_options = ["--main", "README.rdoc"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{inactive_record}
20
+ s.rubygems_version = %q{1.3.1}
21
+ s.summary = %q{InactiveRecord gives you many of the features you know and love from ActiveRecord without the need for a backing database table.}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_development_dependency(%q<newgem>, [">= 1.3.0"])
29
+ s.add_development_dependency(%q<activerecord>, [">= 2.2.0"])
30
+ s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
31
+ else
32
+ s.add_dependency(%q<newgem>, [">= 1.3.0"])
33
+ s.add_dependency(%q<activerecord>, [">= 2.2.0"])
34
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
35
+ end
36
+ else
37
+ s.add_dependency(%q<newgem>, [">= 1.3.0"])
38
+ s.add_dependency(%q<activerecord>, [">= 2.2.0"])
39
+ s.add_dependency(%q<hoe>, [">= 1.8.0"])
40
+ end
41
+ end
@@ -4,5 +4,5 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'inactive_record/base'
5
5
 
6
6
  module InactiveRecord
7
- VERSION = '1.0.0'
7
+ VERSION = '1.0.1'
8
8
  end
@@ -107,6 +107,27 @@ module InactiveRecord
107
107
  def self.human_name
108
108
 
109
109
  end
110
+
111
+ # Allows alternate humanized versions of attributes to be set. For example, an attribute such as 'num_employees' would be
112
+ # converted to 'Num employees' normally using <tt>human_attribute_name</tt>. More descriptive text can be set. Example:
113
+ # attr_human_name 'num_employees' => 'Number of employees'
114
+ def self.attr_human_name(attributes) # :nodoc:
115
+ attributes.stringify_keys!
116
+ write_inheritable_hash("attr_human_name", attributes || {})
117
+
118
+ # assign the current class to each column that is being assigned a new human attribute name
119
+ #self.columns.reject{|c| !attributes.has_key?(c.name)}.each{|c| c.parent_record_class = self}
120
+ end
121
+
122
+ def self.human_name_attributes # :nodoc:
123
+ read_inheritable_attribute("attr_human_name")
124
+ end
125
+
126
+ # Transforms attribute key names into a more humane format, such as "First name" instead of "first_name". Example:
127
+ # Person.human_attribute_name("first_name") # => "First name"
128
+ def self.human_attribute_name(attribute_key_name) #:nodoc:
129
+ (read_inheritable_attribute("attr_human_name") || {})[attribute_key_name.to_s] || ""
130
+ end
110
131
 
111
132
  protected
112
133
 
@@ -114,10 +135,6 @@ module InactiveRecord
114
135
  ValidatingModel.raise_not_implemented_error(*params)
115
136
  end
116
137
 
117
- def self.human_attribute_name(attribute_key_name)
118
- attribute_key_name.humanize
119
- end
120
-
121
138
  alias save raise_not_implemented_error
122
139
  alias update_attribute raise_not_implemented_error
123
140
  alias save! raise_not_implemented_error
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midas-inactive_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - C. Jason Harrelson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-03 00:00:00 -07:00
12
+ date: 2009-06-24 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.2.3
23
+ version: 1.3.0
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
@@ -60,6 +60,7 @@ files:
60
60
  - PostInstall.txt
61
61
  - README.rdoc
62
62
  - Rakefile
63
+ - inactive_record.gemspec
63
64
  - lib/inactive_record.rb
64
65
  - lib/inactive_record/base.rb
65
66
  - script/console