Module: Classy::Yaml::Helpers
- Defined in:
- lib/classy/yaml/helpers.rb
Instance Method Summary collapse
-
#yass(*args) ⇒ String
Fetches utility classes from YAML files based on the provided keys.
Instance Method Details
#yass(*args) ⇒ String
Fetches utility classes from YAML files based on the provided keys. The method follows a priority order:
-
Extra files (highest priority)
-
Default YAML
-
ViewComponent YAMLs (lowest priority)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/classy/yaml/helpers.rb', line 12 def yass(*args) # Start with ViewComponent YAMLs (lowest priority) classy_yamls = Classy::Yaml.cached_engine_yamls.dup # Add default YAML (next priority) default_yaml = Classy::Yaml.cached_default_yaml classy_yamls << default_yaml if default_yaml # Add extra files (highest priority) Classy::Yaml.extra_files.each do |file_path| load_yaml_file(file_path, classy_yamls, "extra") end # Add classy_files (highest priority) classy_files_hash = args.find { |arg| arg.is_a?(Hash) && arg.keys.include?(:classy_files) } || { classy_files: [] } classy_files_hash[:classy_files].each do |file_path| load_yaml_file(file_path, classy_yamls, "classy") end return "" if classy_yamls.blank? skip_base_hash = args.find { |arg| arg.is_a?(Hash) && arg.keys.include?(:skip_base) } || {} keys, classes = flatten_args(values: args) classes += fetch_classes(keys, classy_yamls: classy_yamls, skip_base: skip_base_hash[:skip_base]) classes.flatten.uniq.join(" ") end |