attr_cleaner 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +17 -2
- data/lib/attr_cleaner/railtie.rb +12 -0
- data/lib/attr_cleaner/version.rb +1 -1
- data/lib/attr_cleaner.rb +1 -0
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
= AttrCleaner
|
2
2
|
|
3
|
-
Cleans up your model attributes. Strips leading and trailing space, and turns empty
|
3
|
+
Cleans up your model attributes. Strips leading and trailing space, and turns empty
|
4
|
+
strings into nil.
|
4
5
|
|
5
6
|
== Installing
|
6
7
|
|
7
|
-
|
8
|
+
For Rails 3 with ActiveRecord just add this to your Gemfile:
|
8
9
|
|
9
10
|
gem "attr_cleaner"
|
11
|
+
|
12
|
+
Attr cleaner will play nice with any ORM that writes attributes
|
13
|
+
via a method called `write_attribute`.
|
14
|
+
To get AttrCleaner working with your ORM add this to an initializer file:
|
15
|
+
|
16
|
+
MyOrm.send(:include, AttrCleaner::ModelMixin)
|
17
|
+
|
18
|
+
or, include it into your models:
|
19
|
+
|
20
|
+
include AttrCleaner::ModelMixin
|
21
|
+
|
22
|
+
AttrCleaner can also be used outside of Rails if ActiveSupport 3 is avalable. If you're using
|
23
|
+
AttrCleaner outside of Rails, and it detect ActiveRecord is allready loaded, it will include
|
24
|
+
itself into ActiveRecod. Make sure ActiveRecord is loaded first.
|
10
25
|
|
11
26
|
== Usage
|
12
27
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "rails"
|
2
|
+
require "attr_cleaner"
|
3
|
+
|
4
|
+
module AttrCleaner
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
initializer 'attr_cleaner.include_into_activerecord' do |app|
|
7
|
+
ActiveSupport.on_load(:active_record) do
|
8
|
+
ActiveRecord::Base.send(:include, AttrCleaner::ModuleMixin)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/attr_cleaner/version.rb
CHANGED
data/lib/attr_cleaner.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Thomas Drake-Brockman
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- attr_cleaner.gemspec
|
53
53
|
- lib/attr_cleaner.rb
|
54
54
|
- lib/attr_cleaner/module_mixin.rb
|
55
|
+
- lib/attr_cleaner/railtie.rb
|
55
56
|
- lib/attr_cleaner/version.rb
|
56
57
|
has_rdoc: true
|
57
58
|
homepage: https://rubygems.org/gems/attr_cleaner
|