Exception: Mokio::Exceptions::IsNotMenuRootError

Inherits:
MokioError
  • Object
show all
Defined in:
lib/mokio/exceptions.rb

Overview

Exception used when specified menu object wasn’t root

Instance Attribute Summary collapse

Attributes inherited from MokioError

#message

Instance Method Summary collapse

Methods inherited from MokioError

#to_s

Constructor Details

#initialize(type = :id, arg = nil) ⇒ IsNotMenuRootError

Constructs a IsNotMenuRootError exception

Attributes

  • type - How you search for root

  • arg - Searching argument



52
53
54
55
56
57
58
# File 'lib/mokio/exceptions.rb', line 52

def initialize(type = :id, arg = nil)
	@type    = type
	@message = "Cannot find Menu root for #{type.to_s} = #{arg}"

	@id   = arg if type == :id
	@name = arg if type == :name
end

Instance Attribute Details

#idObject

Given id if type == :id



36
37
38
# File 'lib/mokio/exceptions.rb', line 36

def id
  @id
end

#nameObject

Given name if type == :name



39
40
41
# File 'lib/mokio/exceptions.rb', line 39

def name
  @name
end

#typeObject

How you search for root



42
43
44
# File 'lib/mokio/exceptions.rb', line 42

def type
  @type
end

Instance Method Details

#objObject

Retruns Mokio::Menu object for id or name given to exception



63
64
65
# File 'lib/mokio/exceptions.rb', line 63

def obj
	@id ? Mokio::Menu.find(@id) : Mokio::Menu.find_by_name(@name)
end