class RailsAmp::Config
Public Instance Methods
analytics()
click to toggle source
Return the analytics account, default is ''.
# File lib/rails_amp/config.rb, line 56 def analytics @@analytics ||= config_analytics end
analytics=(analytics)
click to toggle source
Set the analytics account.
# File lib/rails_amp/config.rb, line 61 def analytics=(analytics) @@analytics = analytics end
config_file()
click to toggle source
Return the config file path, default is “#{Rails.root}/config/rails_amp.yml”.
# File lib/rails_amp/config.rb, line 16 def config_file @@config_file ||= "#{Rails.root}/config/rails_amp.yml" end
config_file=(config_file)
click to toggle source
Set the config file path.
# File lib/rails_amp/config.rb, line 21 def config_file=(config_file) @@config_file = config_file end
default_format()
click to toggle source
Return the default amp format, default is :amp
# File lib/rails_amp/config.rb, line 36 def default_format @@default_format ||= config_default_format end
default_format=(default_format)
click to toggle source
Set the default amp format.
# File lib/rails_amp/config.rb, line 41 def default_format=(default_format) @@default_format = default_format.to_sym end
format()
click to toggle source
Return the current format, default is ''. The only configuration value that is not global.
# File lib/rails_amp/config.rb, line 6 def format @format ||= '' end
format=(format)
click to toggle source
Set the current format pseudo-globally, i.e. in the Thread.current hash.
# File lib/rails_amp/config.rb, line 11 def format=(format) @format = format.to_s end
load_config()
click to toggle source
Return the yaml loaded config, default is YAML.load_file(config_file).
# File lib/rails_amp/config.rb, line 26 def load_config @@load_config ||= config_load_config end
load_config=(load_config)
click to toggle source
Set the config by loading yaml.
# File lib/rails_amp/config.rb, line 31 def load_config=(load_config) @@load_config = load_config end
lookup_formats()
click to toggle source
Return the lookup_context formats for amp, default is [:html].
# File lib/rails_amp/config.rb, line 66 def lookup_formats @@lookup_formats ||= config_lookup_formats end
lookup_formats=(lookup_formats)
click to toggle source
Set the lookup_context formats for amp.
# File lib/rails_amp/config.rb, line 71 def lookup_formats=(lookup_formats) @@lookup_formats = lookup_formats end
targets()
click to toggle source
Return the amp enabled controller actions.
# File lib/rails_amp/config.rb, line 46 def targets @@targets ||= config_targets end
targets=(targets)
click to toggle source
Set the amp enabled controller actions.
# File lib/rails_amp/config.rb, line 51 def targets=(targets) @@targets = targets end
Private Instance Methods
config_analytics()
click to toggle source
# File lib/rails_amp/config.rb, line 100 def config_analytics load_config['analytics'] || '' end
config_default_format()
click to toggle source
# File lib/rails_amp/config.rb, line 81 def config_default_format load_config['default_format'].try(:to_sym) || :amp end
config_load_config()
click to toggle source
# File lib/rails_amp/config.rb, line 77 def config_load_config YAML.load_file(config_file) end
config_lookup_formats()
click to toggle source
# File lib/rails_amp/config.rb, line 104 def config_lookup_formats load_config['lookup_formats'].to_s.split(/\s+/).map(&:to_sym).presence || [:html] end
config_targets()
click to toggle source
# File lib/rails_amp/config.rb, line 85 def config_targets targets = load_config['targets'] return {} if targets.blank? if targets.is_a?(Hash) && targets.has_key?('application') return targets end if targets.is_a?(Hash) return targets.map{ |k, v| [k, v.to_s.split(/\s+/)] }.to_h end {} end