Class: Cure::Dsl::Exporters
- Inherits:
-
Object
- Object
- Cure::Dsl::Exporters
- Defined in:
- lib/cure/dsl/exporters.rb
Instance Attribute Summary collapse
-
#processors ⇒ Object
readonly
Returns the value of attribute processors.
Instance Method Summary collapse
- #class_exists?(klass_name) ⇒ TrueClass, FalseClass
-
#initialize ⇒ Exporters
constructor
A new instance of Exporters.
- #method_missing(method_name, **args) ⇒ Cure::Export::BaseBuilder
- #respond_to_missing?(_method_name, _include_private = false) ⇒ TrueClass
Constructor Details
#initialize ⇒ Exporters
Returns a new instance of Exporters.
12 13 14 |
# File 'lib/cure/dsl/exporters.rb', line 12 def initialize @processors = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, **args) ⇒ Cure::Export::BaseBuilder
25 26 27 28 29 30 31 32 33 |
# File 'lib/cure/dsl/exporters.rb', line 25 def method_missing(method_name, **args) klass_name = "Cure::Export::#{method_name.to_s.split("_").map(&:capitalize).join("")}Processor" raise "#{method_name} is not valid" unless class_exists?(klass_name) @processors << Kernel.const_get(klass_name).new( args[:named_range] || "_default", args || {} ) end |
Instance Attribute Details
#processors ⇒ Object (readonly)
Returns the value of attribute processors.
10 11 12 |
# File 'lib/cure/dsl/exporters.rb', line 10 def processors @processors end |
Instance Method Details
#class_exists?(klass_name) ⇒ TrueClass, FalseClass
37 38 39 40 41 42 |
# File 'lib/cure/dsl/exporters.rb', line 37 def class_exists?(klass_name) klass = Module.const_get(klass_name) klass.is_a?(Class) rescue NameError false end |
#respond_to_missing?(_method_name, _include_private = false) ⇒ TrueClass
19 20 21 |
# File 'lib/cure/dsl/exporters.rb', line 19 def respond_to_missing?(_method_name, _include_private=false) true end |