Class: UtilityClasses::UtilityClassReader

Inherits:
Object
  • Object
show all
Defined in:
lib/utility_classes/utility_class_reader.rb

Overview

Provides access to utility classes stored in config

Instance Method Summary collapse

Constructor Details

#initializeUtilityClassReader

Returns a new instance of UtilityClassReader.



12
13
14
15
# File 'lib/utility_classes/utility_class_reader.rb', line 12

def initialize
  @styles = data_from_config
  @last_updated = File.ctime(config_file)
end

Instance Method Details

#for(type, variant: nil) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/utility_classes/utility_class_reader.rb', line 17

def for(type, variant: nil)
  reload_config if config_changed?

  classes = retrieve_classes_for_type(type)
  variant_classes = retrieve_classes_for_variant(type, variant) if variant

  variant_classes ? "#{classes} #{variant_classes}" : classes
end