Skip to content

Commit c6e9206

Browse files
authored
Merge pull request #438 from seanpdoyle/fix-format-docs
Fix inconsistent custom format documentation
2 parents 3f3dd66 + 9efefb6 commit c6e9206

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/active_resource/base.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ module ActiveResource
105105
# To customize how attributes are encoded and decoded, declare a format and override
106106
# its +encode+ and +decode+ methods:
107107
#
108-
# module CamelcaseJsonFormat
109-
# extend ActiveResource::Formats[:json]
108+
# class CamelcaseJsonFormat
109+
# include ActiveResource::Formats[:json]
110110
#
111-
# def self.encode(resource, options = nil)
111+
# def encode(resource, options = nil)
112112
# hash = resource.as_json(options)
113113
# hash = hash.deep_transform_keys! { |key| key.camelcase(:lower) }
114114
# super(hash)
@@ -120,7 +120,7 @@ module ActiveResource
120120
# end
121121
# end
122122
#
123-
# Person.format = CamelcaseJsonFormat
123+
# Person.format = CamelcaseJsonFormat.new
124124
#
125125
# person = Person.new(first_name: "First", last_name: "Last")
126126
# person.encode

test/fixtures/address.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class AddressXMLFormatter
55
include ActiveResource::Formats::XmlFormat
66

77
def decode(xml)
8-
data = ActiveResource::Formats::XmlFormat.decode(xml)
8+
data = super
99
# process address fields
1010
data.each do |address|
1111
address["city_state"] = "#{address['city']}, #{address['state']}"

0 commit comments

Comments
 (0)