Class: Servactory::Internals::Internal

Inherits:
Object
  • Object
show all
Defined in:
lib/servactory/internals/internal.rb

Defined Under Namespace

Classes: Actor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Internal.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/servactory/internals/internal.rb', line 41

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



53
54
55
56
57
58
# File 'lib/servactory/internals/internal.rb', line 53

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.



37
38
39
# File 'lib/servactory/internals/internal.rb', line 37

def collection_of_options
  @collection_of_options
end

#nameObject (readonly)

Returns the value of attribute name.



37
38
39
# File 'lib/servactory/internals/internal.rb', line 37

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



37
38
39
# File 'lib/servactory/internals/internal.rb', line 37

def options
  @options
end

Instance Method Details

#i18n_nameObject



80
81
82
# File 'lib/servactory/internals/internal.rb', line 80

def i18n_name
  system_name.to_s.pluralize
end

#input?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/servactory/internals/internal.rb', line 84

def input?
  false
end

#internal?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/servactory/internals/internal.rb', line 88

def internal?
  true
end

#options_for_checksObject



72
73
74
# File 'lib/servactory/internals/internal.rb', line 72

def options_for_checks
  @collection_of_options.options_for_checks
end

#output?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/servactory/internals/internal.rb', line 92

def output?
  false
end

#register_options(helpers:, options:) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/servactory/internals/internal.rb', line 64

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)


60
61
62
# File 'lib/servactory/internals/internal.rb', line 60

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

#system_nameObject



76
77
78
# File 'lib/servactory/internals/internal.rb', line 76

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