data_display 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/data_display/model_additions.rb +2 -2
- data/lib/data_display/version.rb +1 -1
- data/spec/model_additions_spec.rb +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca8b872e316a12227a086da1891079a9a5783346
|
4
|
+
data.tar.gz: 679aa4fecfc0aec24f67b4b360f7b33a1102c6e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 500aadfba01e2390142b24e447256497bfcb3b5763be779f4ad44d67cc956f34da197ad8057ce953a0adea372eb96f912876c8ae2177489baa140db56483e98a
|
7
|
+
data.tar.gz: ddc499d3e67f609791a4ce66c91b9c1960fadf5ec63b6dc18e9e8377d3b97804167062f415782efc3ec5b30db159c31fd1fc03d37f970720f81c0bf11650a63e
|
@@ -7,8 +7,8 @@ module DataDisplay
|
|
7
7
|
def acts_as_displayable(*args)
|
8
8
|
args = columns.map(&:name) if args.blank?
|
9
9
|
args.each do |attribute|
|
10
|
-
define_method "#{attribute}_display" do
|
11
|
-
__data_display__(send(attribute))
|
10
|
+
define_method "#{attribute}_display" do |format = nil|
|
11
|
+
__data_display__(send(attribute), format)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/data_display/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe DataDisplay::ModelAdditions do
|
4
|
-
let(:user) { create(:user) }
|
4
|
+
let(:user) { create(:user, birthday: Date.new(2001,2,3)) }
|
5
5
|
let(:article){ create(:article) }
|
6
6
|
|
7
7
|
describe 'when model have some displayable attributes' do
|
@@ -14,6 +14,9 @@ describe DataDisplay::ModelAdditions do
|
|
14
14
|
it { user.methods.exclude?(:name_display).must_equal true }
|
15
15
|
it { user.methods.exclude?(:id_display).must_equal true }
|
16
16
|
it { user.methods.exclude?(:email_display).must_equal true }
|
17
|
+
|
18
|
+
it { user.birthday_display.must_equal 'February 03, 2001' }
|
19
|
+
it { user.birthday_display(:short).must_equal 'Feb 03' }
|
17
20
|
end
|
18
21
|
|
19
22
|
describe 'when model have all displayable attributes' do
|