Module: Otoroshi::Sanctuary

Defined in:
lib/otoroshi/sanctuary.rb

Overview

This module is designed to be in a class. This will provide the “property” (ClassMethods#property) method for defining class properties.

Examples:

class Importer
  include Otoroshi::Sanctuary

  property :whatever
  property :number, Integer
  property :numbers, [Integer]
  property :positive_number, Integer, verify: ->(v) { v >= 0 }
  property :number_or_nil, Integer, allow_nil: true
  property :number_with_default, Integer, default: 42
  property :number_in_collection, Integer, one_of: [1, 2, 3, 5, 8, 13, 21, 34]
end

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Extend ClassMethods for the base class



24
25
26
# File 'lib/otoroshi/sanctuary.rb', line 24

def included(base)
  base.extend ClassMethods
end