Sha256: 1fdd3181e6aa6e82d88685e2baaf99943f9fe322a4ce0a22d3fdac5998f292d9
Contents?: true
Size: 722 Bytes
Versions: 36
Compression:
Stored size: 722 Bytes
Contents
module Avo module FieldsCollector def field(field_name, as:, **args, &block) self.fields ||= [] self.fields << parse_field(field_name, as: as, **args, &block) end def parse_field(field_name, as:, **args, &block) matched_field = Avo::App.fields.find do |field| field[:name].to_s == as.to_s end if matched_field.present? && matched_field[:class].present? klass = matched_field[:class] if block klass.new(field_name, **args || {}, &block) else klass.new(field_name, **args || {}) end end end def heading(body, **args) self.fields << Avo::Fields::HeadingField.new(body, **args) end end end
Version data entries
36 entries across 36 versions & 1 rubygems