Sha256: 8f70f46bd7b4cc807d4a6f49beb9034c34ae97580310576d53c555dbe7087fc8
Contents?: true
Size: 804 Bytes
Versions: 26
Compression:
Stored size: 804 Bytes
Contents
# frozen_string_literal: true module Glossarist module Utilities module BooleanAttributes def self.included(base) base.extend(ClassMethods) end def self.extended(base) base.extend(ClassMethods) end module ClassMethods def register_boolean_attributes(attributes) attributes.each do |attribute| register_boolean_attribute(attribute) end end def register_boolean_attribute(attribute) attr_reader attribute define_method("#{attribute}=") do |value| instance_variable_set("@#{attribute}", !!value) end define_method("#{attribute}?") do !!instance_variable_get("@#{attribute}") end end end end end end
Version data entries
26 entries across 26 versions & 2 rubygems