Class: Avo::Loaders::FieldsLoader
- Defined in:
- lib/avo/loaders/fields_loader.rb
Instance Attribute Summary
Attributes inherited from Loader
Instance Method Summary collapse
Methods inherited from Loader
Constructor Details
This class inherits a constructor from Avo::Loaders::Loader
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/avo/loaders/fields_loader.rb', line 8 def method_missing(method, *args, &block) matched_field = Avo::App.fields.find do |field| field[:name].to_s == method.to_s end if matched_field.present? && matched_field[:class].present? klass = matched_field[:class] field = if block.present? klass.new(args[0], **args[1] || {}, &block) else klass.new(args[0], **args[1] || {}) end add_field field end end |
Instance Method Details
#add_field(field) ⇒ Object
4 5 6 |
# File 'lib/avo/loaders/fields_loader.rb', line 4 def add_field(field) @bag.push field end |