Module: ServiceCrud::ClassMethods

Defined in:
lib/service_crud/service_crud.rb

Instance Method Summary collapse

Instance Method Details

#after_create(method = nil, &block) ⇒ Object



41
42
43
44
# File 'lib/service_crud/service_crud.rb', line 41

def after_create(method=nil, &block)
  self.after_creates << method if method
  self.after_creates << block if block 
end

#after_createsObject



59
# File 'lib/service_crud/service_crud.rb', line 59

def after_creates;    @after_creates   ||= []; end

#after_destroy(method = nil, &block) ⇒ Object



51
52
53
54
# File 'lib/service_crud/service_crud.rb', line 51

def after_destroy(method=nil, &block)
  self.after_destroys << method if method
  self.after_destroys << block if block 
end

#after_destroysObject



61
# File 'lib/service_crud/service_crud.rb', line 61

def after_destroys;   @after_destroys  ||= []; end

#after_update(method = nil, &block) ⇒ Object



46
47
48
49
# File 'lib/service_crud/service_crud.rb', line 46

def after_update(method=nil, &block)
  self.after_updates << method if method
  self.after_updates << block if block 
end

#after_updatesObject



60
# File 'lib/service_crud/service_crud.rb', line 60

def after_updates;    @after_updates   ||= []; end

#before_create(method = nil, &block) ⇒ Object



26
27
28
29
# File 'lib/service_crud/service_crud.rb', line 26

def before_create(method=nil, &block)
  self.before_creates << method if method
  self.before_creates << block if block 
end

#before_createsObject



56
# File 'lib/service_crud/service_crud.rb', line 56

def before_creates;   @before_creates  ||= []; end

#before_destroy(method = nil, &block) ⇒ Object



36
37
38
39
# File 'lib/service_crud/service_crud.rb', line 36

def before_destroy(method=nil, &block)
  self.before_destroys << method if method
  self.before_destroys << block if block 
end

#before_destroysObject



58
# File 'lib/service_crud/service_crud.rb', line 58

def before_destroys;  @before_destroys ||= []; end

#before_update(method = nil, &block) ⇒ Object



31
32
33
34
# File 'lib/service_crud/service_crud.rb', line 31

def before_update(method=nil, &block)
  self.before_updates << method if method
  self.before_updates << block if block 
end

#before_updatesObject



57
# File 'lib/service_crud/service_crud.rb', line 57

def before_updates;   @before_updates  ||= []; end

#model(klass = nil) ⇒ Object



8
9
10
11
# File 'lib/service_crud/service_crud.rb', line 8

def model(klass=nil)
  @model ||= klass
  @model || self.to_s.gsub("Controller", "").singularize.constantize
end

#model_attribute_root(root = nil) ⇒ Object



13
14
15
16
# File 'lib/service_crud/service_crud.rb', line 13

def model_attribute_root(root=nil)
  @model_attribute_root ||= root
  @model_attribute_root || self.model.to_s.underscore.to_sym
end

#orm_methodsObject



22
23
24
# File 'lib/service_crud/service_crud.rb', line 22

def orm_methods
  @orm_methods ||= ServiceCrud::DefaultOrm.new
end

#orm_methods!(orm_module) ⇒ Object



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

def orm_methods!(orm_module)
  self.orm_methods.extend orm_module
end