Sha256: 288f75710c16d12cb70c30df5428870b0acdce0aa9265f5307f479dad1424e49
Contents?: true
Size: 602 Bytes
Versions: 3
Compression:
Stored size: 602 Bytes
Contents
module KktShoppe module AssociatedCountries def self.included(base) base.serialize :country_ids, Array base.before_validation { self.country_ids = self.country_ids.map(&:to_i).select { |i| i > 0} if self.country_ids.is_a?(Array) } end def country?(id) id = id.id if id.is_a?(KktShoppe::Country) self.country_ids.is_a?(Array) && self.country_ids.include?(id.to_i) end def countries return [] unless self.country_ids.is_a?(Array) && !self.country_ids.empty? KktShoppe::Country.where(:id => self.country_ids) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
kkt_shoppe-1.1.2 | lib/kkt_shoppe/associated_countries.rb |
kkt_shoppe-1.1.1 | lib/kkt_shoppe/associated_countries.rb |
kkt_shoppe-1.1.0 | lib/kkt_shoppe/associated_countries.rb |