Module: Statelogic::Util
- Defined in:
- lib/statelogic/activerecord.rb
Class Method Summary collapse
- .debug(msg = nil, &block) ⇒ Object
- .defmethod(cls, name, meta = false, &block) ⇒ Object
- .warn(msg = nil, &block) ⇒ Object
Class Method Details
.debug(msg = nil, &block) ⇒ Object
5 6 7 |
# File 'lib/statelogic/activerecord.rb', line 5 def self.debug(msg = nil, &block) ::ActiveRecord::Base.logger.debug(msg, &block) if ::ActiveRecord::Base.logger end |
.defmethod(cls, name, meta = false, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/statelogic/activerecord.rb', line 13 def self.defmethod(cls, name, = false, &block) c = ? cls. : cls unless c.method_defined?(name) c.send(:define_method, name, &block) debug { "Statelogic created #{ ? 'class' : 'instance'} method #{name} on #{cls.name}." } else warn { "Statelogic won't override #{ ? 'class' : 'instance'} method #{name} already defined on #{cls.name}." } nil end end |
.warn(msg = nil, &block) ⇒ Object
9 10 11 |
# File 'lib/statelogic/activerecord.rb', line 9 def self.warn(msg = nil, &block) ::ActiveRecord::Base.logger.warn(msg, &block) if ::ActiveRecord::Base.logger end |