spaceship/lib/spaceship/tunes/availability.rb in fastlane-2.52.0.beta.20170808010002 vs spaceship/lib/spaceship/tunes/availability.rb in fastlane-2.52.0.beta.20170809010003

- old
+ new

@@ -9,38 +9,27 @@ attr_mapping( 'theWorld' => :include_future_territories ) - class << self - # Create a new object based on a hash. - # This is used to create a new object based on the server response. - def factory(attrs) - obj = self.new(attrs) - obj.unfold_territories(attrs['countries']) - return obj - end - - # Create a new object based on a set of territories. - # @param territories (Array of String or Spaceship::Tunes::Territory objects): A list of the territories - # @param params (Hash): Optional parameters (include_future_territories (Bool, default: true) Are future territories included?) - def from_territories(territories = [], params = {}) - obj = self.new - # Detect if the territories attribute is an array of Strings and convert to Territories - obj.territories = - if territories[0].kind_of?(String) - territories.map { |territory| Spaceship::Tunes::Territory.from_code(territory) } - else - territories - end - obj.include_future_territories = params.fetch(:include_future_territories, true) - return obj - end + # Create a new object based on a set of territories. + # @param territories (Array of String or Spaceship::Tunes::Territory objects): A list of the territories + # @param params (Hash): Optional parameters (include_future_territories (Bool, default: true) Are future territories included?) + def self.from_territories(territories = [], params = {}) + obj = self.new + # Detect if the territories attribute is an array of Strings and convert to Territories + obj.territories = + if territories[0].kind_of?(String) + territories.map { |territory| Spaceship::Tunes::Territory.from_code(territory) } + else + territories + end + obj.include_future_territories = params.fetch(:include_future_territories, true) + return obj end - def unfold_territories(attrs) - unfolded_territories = attrs.map { |info| Territory.new(info) } - instance_variable_set(:@territories, unfolded_territories) + def territories + @territories ||= raw_data['countries'].map { |info| Territory.new(info) } end end end end