Module: Feature::RequireAttr

Defined in:
lib/feature/require_attr.rb

Overview

Provide simple class attribute validation via the #require_attr method.

require "feature/require_attr"

class Person
  def format
    require_attr :name, not_to_be: empty
    require_attr :age, to_be_a: Fixnum
    require_attr :jobs, to_respond_to: :each

    ...
  end
end

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.load(owner) ⇒ Object


19
20
21
22
# File 'lib/feature/require_attr.rb', line 19

def self.load(owner)
  return if owner < InstanceMethods
  owner.send(:include, InstanceMethods)
end