Class: Servactory::Outputs::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/servactory/outputs/output.rb

Defined Under Namespace

Classes: Actor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *helpers, option_helpers:, **options) ⇒ Output

Returns a new instance of Output.



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/servactory/outputs/output.rb', line 40

def initialize(
  name,
  *helpers,
  option_helpers:,
  **options
)
  @name = name
  @option_helpers = option_helpers

  register_options(helpers:, options:)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



52
53
54
55
56
57
# File 'lib/servactory/outputs/output.rb', line 52

def method_missing(name, *args, &block)
  option = @collection_of_options.find_by(name:)
  return super if option.nil?

  option.body
end

Instance Attribute Details

#collection_of_optionsObject (readonly)

Returns the value of attribute collection_of_options.



36
37
38
# File 'lib/servactory/outputs/output.rb', line 36

def collection_of_options
  @collection_of_options
end

#nameObject (readonly)

Returns the value of attribute name.



36
37
38
# File 'lib/servactory/outputs/output.rb', line 36

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



36
37
38
# File 'lib/servactory/outputs/output.rb', line 36

def options
  @options
end

Instance Method Details

#i18n_nameObject



79
80
81
# File 'lib/servactory/outputs/output.rb', line 79

def i18n_name
  system_name.to_s.pluralize
end

#input?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/servactory/outputs/output.rb', line 83

def input?
  false
end

#internal?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/servactory/outputs/output.rb', line 87

def internal?
  false
end

#options_for_checksObject



71
72
73
# File 'lib/servactory/outputs/output.rb', line 71

def options_for_checks
  @collection_of_options.options_for_checks
end

#output?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/servactory/outputs/output.rb', line 91

def output?
  true
end

#register_options(helpers:, options:) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/servactory/outputs/output.rb', line 63

def register_options(helpers:, options:)
  merged_options = augment_options_with_helpers(helpers:, options:)
  options_registrar = create_options_registrar(options: merged_options)

  @options = merged_options
  @collection_of_options = options_registrar.collection
end

#respond_to_missing?(name) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/servactory/outputs/output.rb', line 59

def respond_to_missing?(name, *)
  @collection_of_options.names.include?(name) || super
end

#system_nameObject



75
76
77
# File 'lib/servactory/outputs/output.rb', line 75

def system_name
  self.class.name.demodulize.downcase.to_sym
end