to_api 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module ToApi
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
data/lib/to_api.rb CHANGED
@@ -19,7 +19,7 @@ if Object.const_defined? :ActiveRecord
19
19
 
20
20
  to_api_attributes.each do |k, v|
21
21
  attribute_includes = include_hash[k] || []
22
- v = v.to_api(*attribute_includes) if v.respond_to?(:to_api)
22
+ v = v.to_api(*attribute_includes)
23
23
  hash[k] = v
24
24
  end
25
25
 
@@ -70,19 +70,19 @@ end
70
70
 
71
71
  class DateTime
72
72
  def to_api(*includes)
73
- to_s(:db)
73
+ self
74
74
  end
75
75
  end
76
76
 
77
77
  class Date
78
78
  def to_api(*includes)
79
- to_s(:db)
79
+ self
80
80
  end
81
81
  end
82
82
 
83
83
  class Time
84
84
  def to_api(*includes)
85
- to_s(:db)
85
+ self
86
86
  end
87
87
  end
88
88
 
data/spec/to_api_spec.rb CHANGED
@@ -76,9 +76,9 @@ describe '#to_api' do
76
76
  end
77
77
 
78
78
  describe DateTime do
79
- it "returns db string for date time" do
80
- now = DateTime.parse("2001-11-28 04:01:59")
81
- now.to_api.should == "2001-11-28 04:01:59"
79
+ it "returns self" do
80
+ now = DateTime.now
81
+ now.to_api.should == now
82
82
  end
83
83
  describe "ingoring includes" do
84
84
  let(:instance) { DateTime.now }
@@ -87,9 +87,9 @@ describe '#to_api' do
87
87
  end
88
88
 
89
89
  describe Date do
90
- it "returns db string for date" do
91
- now = Date.parse("2001-11-28")
92
- now.to_api.should == "2001-11-28"
90
+ it "returns self" do
91
+ now = Date.today
92
+ now.to_api.should == now
93
93
  end
94
94
  describe "ignoring includes" do
95
95
  let(:instance){ Date.today }
@@ -98,9 +98,9 @@ describe '#to_api' do
98
98
  end
99
99
 
100
100
  describe Time do
101
- it "returns db string for time" do
102
- now = Time.parse("2001-11-28 04:01:59")
103
- now.to_api.should == "2001-11-28 04:01:59"
101
+ it "returns self" do
102
+ now = Time.now
103
+ now.to_api.should == now
104
104
  end
105
105
  describe "ingoring includes" do
106
106
  let(:instance) { Time.now }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Shawn Anderson
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-01-11 00:00:00 -05:00
19
+ date: 2011-01-12 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency