Module: Otoroshi::Sanctuary

Defined in:
lib/otoroshi/sanctuary.rb

Overview

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

Examples:

class Importer
  include Otoroshi::Sanctuary

  property :file_path, String, validate: ->(v) { v.match? /.+\.csv/ }
  property :headers, [TrueClass, FalseClass], default: false
  property :col_sep, String, validate: ->(v) { v.in? [',', ';', '\s', '\t', '|'] }, default: ','
  property :converters, Symbol, validate: ->(v) { v.in? i[integer float date] }, allow_nil: true
end

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Extend ClassMethods for the base class



18
19
20
# File 'lib/otoroshi/sanctuary.rb', line 18

def included(base)
  base.extend ClassMethods
end