Sha256: 1a3d9d9e4f777b148396de8c133fddf4295637ca4c41be8544de07e78b87e5b7
Contents?: true
Size: 601 Bytes
Versions: 6
Compression:
Stored size: 601 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
6 entries across 6 versions & 1 rubygems