Class: Aspekt::Object

Inherits:
Hash
  • Object
show all
Defined in:
lib/aspekt/object.rb

Overview

All Aspekt’s objects are extended from Aspekt::Object.

It extends Hash.

Direct Known Subclasses

Advice, Joinpoint, Pointcut

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Object

Creates a new Aspekt::Object with base class Hash and registres self in class :@all.

Example

class MyClass < Aspekt::Object; end
obj = MyClass.new a: 'b', c: 'd'
obj               # {a: 'b', c: 'd'}

Raises:

  • (ArgumentError)


19
20
21
22
23
24
# File 'lib/aspekt/object.rb', line 19

def initialize opts = {}
  raise ArgumentError, "should be Hash" unless opts.is_a?(Hash)

  self.merge! opts
  self.class.all << self
end

Class Method Details

.allObject

Will be probleby deparated and implemented as aspect

Example

class MyClass < Aspekt::Object; end
object1 = MyClass.new
object2 = MyClass.new
MyClass.all    # will contain object1 and object2


36
37
38
# File 'lib/aspekt/object.rb', line 36

def self.all
  @all ||= []
end