Class: RLM::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/rlm/tool.rb

Constant Summary collapse

CATEGORIES =
%i[read_only write_requires_approval write_allowed dangerous_disabled].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.category(value = nil) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
# File 'lib/rlm/tool.rb', line 14

def category(value = nil)
  return @category || :read_only if value.nil?
  raise ArgumentError, "Unknown category: #{value.inspect}" unless CATEGORIES.include?(value)

  @category = value
end

.description(text = nil) ⇒ Object



8
9
10
11
12
# File 'lib/rlm/tool.rb', line 8

def description(text = nil)
  return @description if text.nil?

  @description = text
end

.inherited(subclass) ⇒ Object



25
26
27
28
29
# File 'lib/rlm/tool.rb', line 25

def inherited(subclass)
  super
  subclass.instance_variable_set(:@description, nil)
  subclass.instance_variable_set(:@category, nil)
end

.registry_nameObject



21
22
23
# File 'lib/rlm/tool.rb', line 21

def registry_name
  @registry_name ||= name.to_s.split("::").last
end

Instance Method Details

#call(**kwargs) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/rlm/tool.rb', line 32

def call(**kwargs)
  raise NotImplementedError, "#{self.class} must implement #call"
end