Module: ServiceCrud::ClassMethods
- Defined in:
- lib/service_crud/service_crud.rb
Instance Method Summary collapse
- #after_create(method = nil, &block) ⇒ Object
- #after_creates ⇒ Object
- #after_destroy(method = nil, &block) ⇒ Object
- #after_destroys ⇒ Object
- #after_update(method = nil, &block) ⇒ Object
- #after_updates ⇒ Object
- #before_create(method = nil, &block) ⇒ Object
- #before_creates ⇒ Object
- #before_destroy(method = nil, &block) ⇒ Object
- #before_destroys ⇒ Object
- #before_update(method = nil, &block) ⇒ Object
- #before_updates ⇒ Object
- #model(klass = nil) ⇒ Object
- #model_attribute_root(root = nil) ⇒ Object
- #orm_methods ⇒ Object
- #orm_methods!(orm_module) ⇒ Object
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_creates ⇒ Object
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_destroys ⇒ Object
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_updates ⇒ Object
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_creates ⇒ Object
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_destroys ⇒ Object
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_updates ⇒ Object
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_methods ⇒ Object
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 |