lib/osm/badge.rb in osm-1.2.8 vs lib/osm/badge.rb in osm-1.2.9
- old
+ new
@@ -7,10 +7,12 @@
# @return [String] the name of the badge
# @!attribute [rw] requirement_notes
# @return [String] a description of the badge
# @!attribute [rw] osm_key
# @return [String] the key for the badge in OSM
+ # @!attribute [rw] osm_long_key
+ # @return [String] the long key for the badge in osm (used for getting stock)
# @!attribute [rw] sections_needed
# @return [Fixnum]
# @!attribute [rw] total_needed
# @return [Fixnum]
# @!attribute [rw] needed_from_section
@@ -19,24 +21,26 @@
# @return [Array<Osm::Badge::Requirement>]
attribute :name, :type => String
attribute :requirement_notes, :type => String
attribute :osm_key, :type => String
+ attribute :osm_long_key, :type => String
attribute :sections_needed, :type => Integer
attribute :total_needed, :type => Integer
attribute :needed_from_section, :type => Object
attribute :requirements, :type => Object
if ActiveModel::VERSION::MAJOR < 4
- attr_accessible :name, :requirement_notes, :osm_key, :sections_needed, :total_needed, :needed_from_section, :requirements
+ attr_accessible :name, :requirement_notes, :osm_key, :osm_long_key, :sections_needed, :total_needed, :needed_from_section, :requirements
end
validates_numericality_of :sections_needed, :only_integer=>true, :greater_than_or_equal_to=>-1
validates_numericality_of :total_needed, :only_integer=>true, :greater_than_or_equal_to=>-1
validates_presence_of :name
validates_presence_of :requirement_notes
validates_presence_of :osm_key
+ validates_presence_of :osm_long_key
validates :needed_from_section, :hash => {:key_type => String, :value_type => Fixnum}
validates :requirements, :array_of => {:item_type => Osm::Badge::Requirement, :item_valid => true}
# @!method initialize
@@ -75,9 +79,10 @@
badge = new(
:name => detail['name'],
:requirement_notes => detail['description'],
:osm_key => detail['shortname'],
+ :osm_long_key => detail['table'],
:sections_needed => config['sectionsneeded'].to_i,
:total_needed => config['totalneeded'].to_i,
:needed_from_section => (config['sections'] || {}).inject({}) { |h,(k,v)| h[k] = v.to_i; h },
)