Module: Coach4rb::Mixin::AutoConstructor

Included in:
Resource::Entity, Resource::Page
Defined in:
lib/coach4rb/mixin/auto_constructor.rb

Overview

This module provides an auto constructor and automatically provides setters and getters for instance variables.

The instance variables are created by the given hash which is passed to the constructor.

The keys in the hash are used as instance variable names and the corresponding values are used to initialize the instance variable values.

Examples

class Test
    include Behaviours::AutoConstructor
end

test = Test.new { name: 'alex' }
test.name # => 'alex'

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



25
26
27
# File 'lib/coach4rb/mixin/auto_constructor.rb', line 25

def self.included(base)
  base.send :include, InstanceMethods
end