Module: Feature::BasicInitialize

Defined in:
lib/feature/basic_initialize.rb

Overview

Provide a basic initializer for a class.

require "feature/basic_initialize"

class Person
  Feature::BasicInitialize.load(self)

  attr_accessor :name, :age

  def self.defaults
    {likes_coffee: true}
  end
end

Person.new(name: "Joe", age: 29)

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.load(owner) ⇒ Object


21
22
23
24
# File 'lib/feature/basic_initialize.rb', line 21

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