Class: ReeRoutes::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionObject

Returns the value of attribute action.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def action
  @action
end

#audit=(value) ⇒ Object (writeonly)

Sets the attribute audit

Parameters:

  • value

    the value to set the attribute audit to.



8
9
10
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 8

def audit=(value)
  @audit = value
end

#beforeObject

Returns the value of attribute before.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def before
  @before
end

#overrideObject

Returns the value of attribute override.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def override
  @override
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def path
  @path
end

#redirectObject

Returns the value of attribute redirect.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def redirect
  @redirect
end

#request_methodObject

Returns the value of attribute request_method.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def request_method
  @request_method
end

#respond_toObject

Returns the value of attribute respond_to.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def respond_to
  @respond_to
end

#routeObject

Returns the value of attribute route.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def route
  @route
end

#sectionsObject

Returns the value of attribute sections.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def sections
  @sections
end

#serializerObject

Returns the value of attribute serializer.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def serializer
  @serializer
end

#summaryObject

Returns the value of attribute summary.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def summary
  @summary
end

#visibilityObject

Returns the value of attribute visibility.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def visibility
  @visibility
end

#warden_scopesObject

Returns the value of attribute warden_scopes.



4
5
6
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 4

def warden_scopes
  @warden_scopes
end

Instance Method Details

#audit_declared?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 29

def audit_declared?
  !@audit.nil?
end

#audit_on_annotation?Boolean

audit :on_annotation — a public route that the client calls for its own data and a staff member calls for someone else's. The event is always assembled, but it only reaches the sink if the code annotated the call; auditing such a route unconditionally would bury the staff access under every ordinary client request.

Returns:

  • (Boolean)


38
39
40
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 38

def audit_on_annotation?
  @audit == :on_annotation
end

#audited?Boolean

Auditing is declared at the route and nowhere else. Deriving it from visibility would work just as well and read far worse: whether a call lands in the access trail is exactly the kind of fact that must be visible where the route is written, not inferred from a flag that means something else. audit is mandatory on admin paths (see DSL#define_route), so the audited set still cannot drift away from the routes that touch client data.

Returns:

  • (Boolean)


25
26
27
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 25

def audited?
  @audit == true || @audit == :on_annotation
end

#internal?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 15

def internal?
  !public?
end

#public?Boolean

Routing always includes every route; visibility only affects generated docs.

Returns:

  • (Boolean)


11
12
13
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 11

def public?
  visibility.nil? || visibility == :public
end

#valid?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 42

def valid?
  !action.nil? && !summary.nil? && !warden_scopes.nil? && !warden_scopes.empty?
end

#warden_scopeObject



50
51
52
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 50

def warden_scope
  @warden_scopes&.first
end

#warden_scope=(scope) ⇒ Object



54
55
56
# File 'lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb', line 54

def warden_scope=(scope)
  @warden_scopes = Array(scope)
end