module MITS::V3_0::Mapper::PetPolicyMapper
Public Instance Methods
pet_policies(tags, entity = PetPolicy, secondary_entity = Pet)
click to toggle source
# File lib/mits/v3.0/mapper/pet_policy_mapper.rb, line 5 def pet_policies(tags, entity = PetPolicy, secondary_entity = Pet) tags = [tags] unless tags.is_a? Array tags.map { |tag| pet_policy(tag, entity, secondary_entity) } end
pet_policy(tag, entity = PetPolicy, secondary_entity = Pet)
click to toggle source
# File lib/mits/v3.0/mapper/pet_policy_mapper.rb, line 10 def pet_policy(tag, entity = PetPolicy, secondary_entity = Pet) if bool(tag[:Allowed]) entity.new(allowed: true, care: bool(tag[:PetCare]), deposit: try(tag[:Deposit], :to_f), fee: try(tag[:Fee], :to_f), pets: pets(tag[:Pets], secondary_entity), rent: try(tag[:Rent], :to_f), restrictions: tag[:Restrictions]) else entity.new(allowed: false) end end
pets(tags, entity = Pet)
click to toggle source
# File lib/mits/v3.0/mapper/pet_policy_mapper.rb, line 24 def pets(tags, entity = Pet) tags = [tags] unless tags.is_a? Array tags.map do |tag| entity.new(count: tag[:Count].to_i, description: tag[:Description], size: tag[:Size], weight: tag[:Weight], type: tag[:PetType]) end end