Sha256: 4a44540a0df24f4b0b0d4d651468a00655430271ba3d4b958821aadb4eb52b80

Contents?: true

Size: 457 Bytes

Versions: 1

Compression:

Stored size: 457 Bytes

Contents

# frozen_string_literal: true
module WannabeBool::Attributes
  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods
    def attr_wannabe_bool(*attributes)
      attributes.each do |attr|
        raise ArgumentError, "#{attr} method is not defined." unless method_defined?(attr)

        next if method_defined?("#{attr}?")

        define_method("#{attr}?") do
          send(attr).to_b
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wannabe_bool-0.7.1 lib/wannabe_bool/attributes.rb