Sha256: 84893d259ca616e35e59e687947eab8451575862c6ef795dee9278df5176d7a7
Contents?: true
Size: 823 Bytes
Versions: 17
Compression:
Stored size: 823 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 value.present? end end private def attribute?(attribute_name) query_attribute(attribute_name) end end end
Version data entries
17 entries across 17 versions & 1 rubygems