Sha256: 58e678671d700ca75bee6501df9300089d7a3d229fdad8d6b807beafead8e4ad

Contents?: true

Size: 516 Bytes

Versions: 1

Compression:

Stored size: 516 Bytes

Contents

module Recliner
  module AttributeMethods
    module Query
      extend ActiveSupport::Concern
      
      included do
        attribute_method_suffix "?"
      end
      
      # Returns true if the attribute is not blank (i.e. it has some value). Otherwise returns false.
      def query_attribute(name)
        !read_attribute(name).blank?
      end
      
    private
      # Handle *? for method_missing.
      def attribute?(attribute_name)
        query_attribute(attribute_name)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
recliner-0.0.1 lib/recliner/attribute_methods/query.rb