Class: Capsium::Package::RoutesConfig

Inherits:
Shale::Mapper
  • Object
show all
Defined in:
lib/capsium/package/routes_config.rb

Instance Method Summary collapse

Instance Method Details

#add(route, target) ⇒ Object



49
50
51
52
53
54
# File 'lib/capsium/package/routes_config.rb', line 49

def add(route, target)
  target = RouteTarget.new(file: target) if target.is_a?(String)
  r = Route.new(path: route, target: target)
  @routes << r
  r
end

#remove(route) ⇒ Object



63
64
65
66
# File 'lib/capsium/package/routes_config.rb', line 63

def remove(route)
  r = resolve(route)
  @routes.delete(r)
end

#resolve(route) ⇒ Object



45
46
47
# File 'lib/capsium/package/routes_config.rb', line 45

def resolve(route)
  routes.detect { |r| r.path == route }
end

#sort!Object



68
69
70
71
# File 'lib/capsium/package/routes_config.rb', line 68

def sort!
  @routes.sort_by!(&:path)
  self
end

#update(route, updated_route, updated_target) ⇒ Object



56
57
58
59
60
61
# File 'lib/capsium/package/routes_config.rb', line 56

def update(route, updated_route, updated_target)
  r = resolve(route)
  r.path = updated_route
  r.target = updated_target
  r
end