Class: Log::Message
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Log::Message
- Defined in:
- app/models/log/message.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#_get_artifact ⇒ Object
Store the old artifact and artifact= functions for later usage.
- #_set_artifact ⇒ Object
-
#artifact ⇒ Object
Returns either the model, or the object.
-
#artifact=(val) ⇒ Object
Assignment overriden to allow the model to be used as well.
-
#artifact_type ⇒ Object
Finds the class of object which we’re dealing with.
- #level=(level) ⇒ Object
- #valid_levels ⇒ Object
Class Method Details
.valid_levels ⇒ Object
9 10 11 |
# File 'app/models/log/message.rb', line 9 def self.valid_levels [:info, :warning, :error] end |
Instance Method Details
#_get_artifact ⇒ Object
Store the old artifact and artifact= functions for later usage
22 |
# File 'app/models/log/message.rb', line 22 alias_method :_get_artifact, :artifact |
#_set_artifact ⇒ Object
23 |
# File 'app/models/log/message.rb', line 23 alias_method :_set_artifact, :artifact= |
#artifact ⇒ Object
Returns either the model, or the object
26 27 28 |
# File 'app/models/log/message.rb', line 26 def artifact _get_artifact.nil? ? artifact_type : _get_artifact end |
#artifact=(val) ⇒ Object
Assignment overriden to allow the model to be used as well
31 32 33 34 35 36 37 |
# File 'app/models/log/message.rb', line 31 def artifact= val if val.is_a? Class self[:artifact_type] = val.model_name else _set_artifact val end end |
#artifact_type ⇒ Object
Finds the class of object which we’re dealing with
40 41 42 |
# File 'app/models/log/message.rb', line 40 def artifact_type self[:artifact_type].nil? ? nil : self[:artifact_type].constantize end |
#level=(level) ⇒ Object
44 45 46 |
# File 'app/models/log/message.rb', line 44 def level= level super level.to_sym end |
#valid_levels ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/models/log/message.rb', line 13 def valid_levels if artifact_type artifact_type.valid_log_levels || self.class.valid_levels else self.class.valid_levels end end |