Sha256: 3a0e24f31bccd6b4e0295af0ebf2cf7bc96232f6e340438c956bc14c14a5b6a7
Contents?: true
Size: 607 Bytes
Versions: 1
Compression:
Stored size: 607 Bytes
Contents
module PluginAWeek #:nodoc: module AttributePredicates module ActiveRecord private # For Strings, returns true when value is: # * "true" # * "t" # # For Integers, returns true when value is: # * 1 def attr_predicate(symbol) define_method("#{symbol}?") do ::ActiveRecord::ConnectionAdapters::Column.value_to_boolean(instance_variable_get("@#{symbol}")) end end end end end ActiveRecord::Base.class_eval do extend PluginAWeek::AttributePredicates::ActiveRecord end if defined?(ActiveRecord)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
attribute_predicates-0.1.0 | lib/attribute_predicates/extensions/active_record.rb |