Sha256: 2b2d6c6f583cb0f1af7d0bb343ef673d69879bbb98627139bd64673d84ab7122
Contents?: true
Size: 405 Bytes
Versions: 2
Compression:
Stored size: 405 Bytes
Contents
module AttrExtras::AttrQuery def self.define_with_suffix(klass, suffix, *names) names.each do |name| name = name.to_s raise "#{__method__} wants `#{name}?`, not `#{name}`." unless name.end_with?("?") klass.send(:define_method, name) do # def foo? !!send("#{name.chop}#{suffix}") # !!send("foo_id") end # end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
attr_extras-2.1.0 | lib/attr_extras/attr_query.rb |
attr_extras-2.0.1 | lib/attr_extras/attr_query.rb |