Sha256: 6c7fb7e524d6fb7a880821b2844a63416daee797cafae958b94fffd58f560b87
Contents?: true
Size: 559 Bytes
Versions: 3
Compression:
Stored size: 559 Bytes
Contents
module JsonAttributes::LegacyPredicates extend ActiveSupport::Concern class_methods do def define_question_methods @json_attrs.each do |attribute| define_method :"#{attribute}?" do !!(self.send(self.class.instance_variable_get(:@field)) && self.send(self.class.instance_variable_get(:@field))[attribute.to_s]) end define_singleton_method :"find_by_#{attribute}" do |value| self.where("#{self.instance_variable_get(:@field)}->>'#{attribute}' = ?", value).first end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems