Sha256: 0d8c5b3e8e0be630daac097e37e587bff5209f1c25ecbbefa549c5f5aefc925a
Contents?: true
Size: 768 Bytes
Versions: 58
Compression:
Stored size: 768 Bytes
Contents
module Graphiti module Extensions # Turns ruby ? methods into is_ attributes # # @example Basic Usage # boolean_attribute :active? # # # equivalent do # def is_active # @object.active? # end module BooleanAttribute def self.included(klass) klass.extend ClassMethods end module ClassMethods # Register a boolean attribute # @param name the corresponding ? method # @param [Hash] options Normal .attribute options def boolean_attribute(name, options = {}, &blk) blk ||= proc { @object.public_send(name) } field_name = :"is_#{name.to_s.gsub('?', '')}" attribute field_name, options, &blk end end end end end
Version data entries
58 entries across 58 versions & 1 rubygems