Sha256: e6aa1fd2977c26c827ba79471e628c8c081265e6e7f369f73e57adac7f8d6b9d
Contents?: true
Size: 910 Bytes
Versions: 1
Compression:
Stored size: 910 Bytes
Contents
require "active_support/concern" require "active_support/core_ext/object/blank" module ActiveRemote # QueryAttributes provides instance methods for querying attributes. # # @example Usage # class Person < ::ActiveRemote::Base # attribute :name # end # # person = Person.new # person.name? #=> false # person.name = "Chris Griego" # person.name? #=> true # module QueryAttributes extend ::ActiveSupport::Concern included do attribute_method_suffix "?" end def query_attribute(attr_name) value = self[attr_name] case value when true then true when false, nil then false else if value.respond_to?(:zero?) !value.zero? else value.present? end end end private def attribute?(attribute_name) query_attribute(attribute_name) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_remote-5.0.0.pre | lib/active_remote/query_attributes.rb |