Sha256: 710c964a958aa72da0920580701f8b5aef29972279cb12b316b4ee9f28a23f21
Contents?: true
Size: 743 Bytes
Versions: 18
Compression:
Stored size: 743 Bytes
Contents
# Adds list of toggleable attributes to model # # @author Maxim Khan-Magomedov <maxim.km@gmail.com> module Toggleable extend ActiveSupport::Concern included do class_attribute :toggleable_attributes, instance_predicate: false, instance_accessor: false # @param [String, Symbol] attribute # @return [Hash] def toggle_parameter(attribute) return unless self::toggleable_attributes.include? attribute.to_sym toggle! attribute { attribute => self[attribute] } end end module ClassMethods private # @param [Array<Symbol, String>] attributes def toggleable(*attributes) cattr_accessor :toggleable_attributes self.toggleable_attributes = attributes.flatten end end end
Version data entries
18 entries across 18 versions & 1 rubygems