Class: Embarista::DynamicIndex::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/embarista/dynamic_index/context.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_config, manifest_id, manifest, assets_base_url) ⇒ Context

Returns a new instance of Context.



6
7
8
9
10
11
# File 'lib/embarista/dynamic_index/context.rb', line 6

def initialize(app_config, manifest_id, manifest, assets_base_url)
  @app_config = app_config
  @manifest_id = manifest_id
  @manifest = manifest
  @assets_base_url = assets_base_url
end

Instance Attribute Details

#app_configObject (readonly)

Returns the value of attribute app_config.



4
5
6
# File 'lib/embarista/dynamic_index/context.rb', line 4

def app_config
  @app_config
end

#assets_base_urlObject (readonly)

Returns the value of attribute assets_base_url.



4
5
6
# File 'lib/embarista/dynamic_index/context.rb', line 4

def assets_base_url
  @assets_base_url
end

#manifestObject (readonly)

Returns the value of attribute manifest.



4
5
6
# File 'lib/embarista/dynamic_index/context.rb', line 4

def manifest
  @manifest
end

#manifest_idObject (readonly)

Returns the value of attribute manifest_id.



4
5
6
# File 'lib/embarista/dynamic_index/context.rb', line 4

def manifest_id
  @manifest_id
end

Class Method Details

.context(manifest_id, assets_base_url = App.assets_base_url) ⇒ Object



18
19
20
21
# File 'lib/embarista/dynamic_index/context.rb', line 18

def self.context(manifest_id, assets_base_url=App.assets_base_url)
  manifest = load_manifest(manifest_id)
  self.new(App.config, manifest_id, manifest, assets_base_url)
end

.load_manifest(manifest_id) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/embarista/dynamic_index/context.rb', line 23

def self.load_manifest(manifest_id)
  if manifest_id == 'dev'
    {}
  else
    YAML.load_file("tmp/public/#{manifest_id}.yml")
  end
end

Instance Method Details

#manifest_url(source) ⇒ Object



13
14
15
16
# File 'lib/embarista/dynamic_index/context.rb', line 13

def manifest_url(source)
  source = manifest[source] || source
  assets_base_url + source
end