active_record_ignored_attributes 0.0.1 → 0.0.2
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.md
CHANGED
@@ -86,9 +86,9 @@ If you want to override the defaults instead of appending to them, just don't re
|
|
86
86
|
|
87
87
|
Now that you've declared which attributes you don't really care about, how about making it so you don't have to see them in your `inspect` output too? (The output from `inspect` is verbose enough as it is!!)
|
88
88
|
|
89
|
-
|
89
|
+
`object.inspect_without_ignored_attributes` will give you the same output as the default `inspect` but without all those ignored attributes (except for `id` — `id` is always included, even if it's listed in `ignored_attributes`)):
|
90
90
|
|
91
|
-
address.inspect_without_ignored_attributes # => "#<Address address: nil, city: nil, country: nil, postal_code: nil, state: nil>"
|
91
|
+
address.inspect_without_ignored_attributes # => "#<Address id: 1, address: nil, city: nil, country: nil, postal_code: nil, state: nil>"
|
92
92
|
|
93
93
|
# Compared to:
|
94
94
|
address.inspect # => "#<Address id: 1, name: nil, address: nil, city: nil, state: nil, postal_code: nil, country: nil, created_at: \"2011-08-19 18:07:39\", updated_at: \"2011-08-19 18:07:39\">"
|
@@ -14,7 +14,12 @@ module ActiveRecordIgnoredAttributes::Inspect
|
|
14
14
|
bracket(*brackets)
|
15
15
|
end
|
16
16
|
|
17
|
+
def attributes_for_inspect
|
18
|
+
[:id].map(&:to_s) +
|
19
|
+
(attributes.keys - self.class.ignored_attributes.map(&:to_s))
|
20
|
+
end
|
21
|
+
|
17
22
|
def inspect_without_ignored_attributes
|
18
|
-
inspect_with(
|
23
|
+
inspect_with(attributes_for_inspect)
|
19
24
|
end
|
20
25
|
end
|
data/spec/inspect_spec.rb
CHANGED
@@ -3,18 +3,22 @@ require 'spec_helper'
|
|
3
3
|
describe Address do
|
4
4
|
describe 'inspect_without_ignored_attributes' do
|
5
5
|
let(:address) { Address.create }
|
6
|
-
it do
|
7
|
-
address.inspect_without_ignored_attributes.
|
6
|
+
it "should include id" do
|
7
|
+
address.inspect_without_ignored_attributes.should match(/id:/)
|
8
|
+
end
|
9
|
+
it "should not include the other ignored_attributes" do
|
8
10
|
address.inspect_without_ignored_attributes.should_not match(/name:/)
|
9
11
|
address.inspect_without_ignored_attributes.should_not match(/created_at:/)
|
10
|
-
|
11
|
-
|
12
|
+
end
|
13
|
+
it "should match what we expect it to look like" do
|
14
|
+
address.inspect_without_ignored_attributes.should match(/#<Address id: \d+, address: nil, city: nil, country: nil, postal_code: nil, state: nil>/)
|
15
|
+
address.original_inspect.should match(/#<Address id: \d+, .* created_at: ".*", updated_at: ".*">/)
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
15
19
|
describe 'inspect' do
|
16
20
|
let(:address) { Address.create }
|
17
|
-
|
21
|
+
specify do
|
18
22
|
address.inspect.should match(/{Address id: \d+, name: nil, address: nil, city: nil, state: nil, postal_code: nil, country: nil}/)
|
19
23
|
end
|
20
24
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: active_record_ignored_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tyler Rick
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-21 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|