lib/osm/badge.rb in osm-1.2.22 vs lib/osm/badge.rb in osm-1.2.23
- old
+ new
@@ -322,18 +322,18 @@
def self.module_completion_data(api, badge, options={})
fetched_this_time = @module_completion_data.nil? # Flag to ensure we only get the data once (at most) per invocation
@module_completion_data = get_module_completion_data(api, options) if fetched_this_time
if @module_completion_data[badge.id].nil? && !fetched_this_time
- @module_completion_data = fetch_from_osm
+ @module_completion_data = get_module_completion_data(api, options)
fetched_this_time = true
end
data = @module_completion_data[badge.id]
raise ArgumentError, "That badge does't exist (bad ID)." if data.nil?
if data[badge.version].nil? && !fetched_this_time
- @module_completion_data = fetch_from_osm
+ @module_completion_data = get_module_completion_data(api, options)
data = @module_completion_data[badge.id]
fetched_this_time = true
end
data = data[badge.version]
raise ArgumentError, "That badge does't exist (bad version)." if data.nil?
@@ -509,10 +509,12 @@
end # Class RequirementModule
class Data < Osm::Model
+ SORT_BY = [:badge, :section_id, :member_id]
+
# @!attribute [rw] member_id
# @return [Fixnum] ID of the member this data relates to
# @!attribute [rw] first_name
# @return [Fixnum] the member's first name
# @!attribute [rw] last_name
@@ -839,17 +841,9 @@
if due_updated && awarded_updated
reset_changed_attributes
end
return requirements_updated && due_updated && awarded_updated
- end
-
- # Compare Badge::Data based on badge, section_id then member_id
- def <=>(another)
- result = self.badge <=> another.try(:badge)
- result = self.section_id <=> another.try(:section_id) if result == 0
- result = self.member_id <=> another.try(:member_id) if result == 0
- return result
end
def inspect
Osm.inspect_instance(self, {:replace_with => {'badge' => :name}})
end