Skip to content

Commit

Permalink
Added skipping of deprecated values
Browse files Browse the repository at this point in the history
(to prevent workarounds for deprecated values)
  • Loading branch information
anlek authored and bcurren committed Feb 13, 2014
1 parent 954afce commit 7357dac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/freshbooks/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def self.new_from_xml(xml_root)
self.schema_definition.members.each do |member_name, member_options|
node = xml_root.elements[member_name.dup]
next if node.nil?
next if XmlSerializer.deprecated? node

value = FreshBooks::XmlSerializer.to_value(node, member_options[:type])
object.send("#{member_name}=", value)
Expand Down
5 changes: 5 additions & 0 deletions lib/freshbooks/xml_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ def self.to_node(member_name, value, type)
def self.create_serializer(type)
"FreshBooks::XmlSerializer::#{type.to_s.classify}Serializer".constantize
end

def self.deprecated?(node)
!node.attribute('deprecated').nil?
end

end
end
4 changes: 2 additions & 2 deletions lib/freshbooks/xml_serializer/serializers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def self.to_node(member_name, value)

def self.to_value(xml_val)
xml_val.elements.map { |elem|
FreshBooks::const_get(elem.name.camelize)::new_from_xml(elem)
}
FreshBooks::const_get(elem.name.camelize)::new_from_xml(elem) unless XmlSerializer.deprecated? elem
}.compact
end
end

Expand Down

0 comments on commit 7357dac

Please sign in to comment.