Class: Turbo::PathConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/turbo/path_configuration/path_configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#delegateObject

Returns the value of attribute delegate.



4
5
6
# File 'lib/turbo/path_configuration/path_configuration.rb', line 4

def delegate
  @delegate
end

#loaderObject

Returns the value of attribute loader.



4
5
6
# File 'lib/turbo/path_configuration/path_configuration.rb', line 4

def loader
  @loader
end

#rulesObject

Returns the value of attribute rules.



4
5
6
# File 'lib/turbo/path_configuration/path_configuration.rb', line 4

def rules
  @rules
end

#settingsObject

Returns the value of attribute settings.



4
5
6
# File 'lib/turbo/path_configuration/path_configuration.rb', line 4

def settings
  @settings
end

#sourcesObject

Returns the value of attribute sources.



4
5
6
# File 'lib/turbo/path_configuration/path_configuration.rb', line 4

def sources
  @sources
end

Instance Method Details

#initWithSources(sources) ⇒ Object

Multiple sources will be loaded in order Remote sources should be last since they’re loaded async



7
8
9
10
11
12
# File 'lib/turbo/path_configuration/path_configuration.rb', line 7

def initWithSources(sources)
  self.sources = sources
  self.rules = []
  load
  self
end

#propertiesForPath(path) ⇒ Object

Returns a merged hash containing all the properties that match this path



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/turbo/path_configuration/path_configuration.rb', line 25

def propertiesForPath(path)
  #source = NSString.stringWithContentsOfURL(url, encoding: NSUTF8StringEncoding, error: nil)
  properties = {}

  rules.each do |rule|
    if rule.match(path)
      properties.merge!(rule.properties)
    end
  end
  properties
end

#propertiesForURL(url) ⇒ Object

Returns a merged hash containing all the properties that match this url Note: currently only looks at path, not query, but most likely will add query support in the future, so it’s best to always use this over the path variant unless you’re sure you’ll never need to reference other parts of the URL in the future



19
20
21
# File 'lib/turbo/path_configuration/path_configuration.rb', line 19

def propertiesForURL(url)
  propertiesForPath(url.path)
end