Class: GitAuth::Message
- Inherits:
-
Object
- Object
- GitAuth::Message
- Defined in:
- lib/gitauth/message.rb
Constant Summary collapse
- TEMPLATES =
YAML.load_file(BASE_DIR.join("resources", "messages.yml"))
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
-
#variables ⇒ Object
Returns the value of attribute variables.
Class Method Summary collapse
-
.error(name = :unknown) ⇒ Object
Handy accessor / generate methods for a given error code.
- .notice(name = :unknown) ⇒ Object
- .warning(name = :unknown) ⇒ Object
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(type, name, variables = {}) ⇒ Message
constructor
A new instance of Message.
- #success? ⇒ Boolean
Constructor Details
#initialize(type, name, variables = {}) ⇒ Message
Returns a new instance of Message.
28 29 30 31 32 33 34 |
# File 'lib/gitauth/message.rb', line 28 def initialize(type, name, variables = {}) @type = type @name = name @variables = {} variables.each_pair { |k,v| @variables[k.to_s] = v } end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
26 27 28 |
# File 'lib/gitauth/message.rb', line 26 def @message end |
#name ⇒ Object
Returns the value of attribute name.
26 27 28 |
# File 'lib/gitauth/message.rb', line 26 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
26 27 28 |
# File 'lib/gitauth/message.rb', line 26 def type @type end |
#variables ⇒ Object
Returns the value of attribute variables.
26 27 28 |
# File 'lib/gitauth/message.rb', line 26 def variables @variables end |
Class Method Details
.error(name = :unknown) ⇒ Object
Handy accessor / generate methods for a given error code.
48 49 50 |
# File 'lib/gitauth/message.rb', line 48 def error(name = :unknown) new(:error, name) end |
.notice(name = :unknown) ⇒ Object
52 53 54 |
# File 'lib/gitauth/message.rb', line 52 def notice(name = :unknown) new(:notice, name) end |
.warning(name = :unknown) ⇒ Object
56 57 58 |
# File 'lib/gitauth/message.rb', line 56 def warning(name = :unknown) new(:warning, name) end |
Instance Method Details
#error? ⇒ Boolean
40 41 42 |
# File 'lib/gitauth/message.rb', line 40 def error? @type.to_sym == :error end |
#success? ⇒ Boolean
36 37 38 |
# File 'lib/gitauth/message.rb', line 36 def success? @type.to_sym == :notice end |