Class: GitAuth::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/gitauth/message.rb

Constant Summary

TEMPLATES =
YAML.load_file(BASE_DIR.join("resources", "messages.yml"))

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Message) initialize(type, name, variables = {})

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 }
  auto_set_message!
end

Instance Attribute Details

- (Object) message

Returns the value of attribute message



26
27
28
# File 'lib/gitauth/message.rb', line 26

def message
  @message
end

- (Object) name

Returns the value of attribute name



26
27
28
# File 'lib/gitauth/message.rb', line 26

def name
  @name
end

- (Object) type

Returns the value of attribute type



26
27
28
# File 'lib/gitauth/message.rb', line 26

def type
  @type
end

- (Object) variables

Returns the value of attribute variables



26
27
28
# File 'lib/gitauth/message.rb', line 26

def variables
  @variables
end

Class Method Details

+ (Object) error(name = :unknown)

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

+ (Object) notice(name = :unknown)



52
53
54
# File 'lib/gitauth/message.rb', line 52

def notice(name = :unknown)
  new(:notice, name)
end

+ (Object) warning(name = :unknown)



56
57
58
# File 'lib/gitauth/message.rb', line 56

def warning(name = :unknown)
  new(:warning, name)
end

Instance Method Details

- (Boolean) error?

Returns:

  • (Boolean)


40
41
42
# File 'lib/gitauth/message.rb', line 40

def error?
  @type.to_sym == :error
end

- (Boolean) success?

Returns:

  • (Boolean)


36
37
38
# File 'lib/gitauth/message.rb', line 36

def success?
  @type.to_sym == :notice
end