Class: EasyCallbacks::Models::TargetClass

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_callbacks/models/target_class.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target_class) ⇒ TargetClass

Returns a new instance of TargetClass.



8
9
10
11
# File 'lib/easy_callbacks/models/target_class.rb', line 8

def initialize(target_class)
  self.target_class = target_class
  self.callbacks_repository = ::EasyCallbacks::Repositories::CallbacksRepository.new self
end

Instance Attribute Details

#callbacks_repositoryObject

Returns the value of attribute callbacks_repository.



6
7
8
# File 'lib/easy_callbacks/models/target_class.rb', line 6

def callbacks_repository
  @callbacks_repository
end

#target_classObject

Returns the value of attribute target_class.



6
7
8
# File 'lib/easy_callbacks/models/target_class.rb', line 6

def target_class
  @target_class
end

Instance Method Details

#add_callback(callback_type, target_method_name, callback_method_name, &callback_block) ⇒ Object



13
14
15
# File 'lib/easy_callbacks/models/target_class.rb', line 13

def add_callback(callback_type, target_method_name, callback_method_name, &callback_block)
  callbacks_repository.find_or_add callback_type, target_method_name, callback_method_name, &callback_block
end

#get_callbacks_for(callback_type, target_method_name) ⇒ Object



17
18
19
# File 'lib/easy_callbacks/models/target_class.rb', line 17

def get_callbacks_for(callback_type, target_method_name)
  callbacks_repository.get_callbacks_for callback_type, target_method_name
end