Class: LeanCloud::Route
- Inherits:
-
Object
- Object
- LeanCloud::Route
- Defined in:
- lib/lean_cloud/route.rb
Instance Attribute Summary collapse
-
#match ⇒ Object
Returns the value of attribute match.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#request ⇒ Object
Returns the value of attribute request.
Instance Method Summary collapse
-
#initialize(name, options, match = false) ⇒ Route
constructor
A new instance of Route.
- #url(*args) ⇒ Object
Constructor Details
#initialize(name, options, match = false) ⇒ Route
Returns a new instance of Route.
4 5 6 7 8 9 10 |
# File 'lib/lean_cloud/route.rb', line 4 def initialize(name, , match=false) [:on] ||= :collection @name = name @request = [:via] ||= :get @match = match = end |
Instance Attribute Details
#match ⇒ Object
Returns the value of attribute match.
3 4 5 |
# File 'lib/lean_cloud/route.rb', line 3 def match @match end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/lean_cloud/route.rb', line 3 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/lean_cloud/route.rb', line 3 def end |
#request ⇒ Object
Returns the value of attribute request.
3 4 5 |
# File 'lib/lean_cloud/route.rb', line 3 def request @request end |
Instance Method Details
#url(*args) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/lean_cloud/route.rb', line 12 def url(*args) namespace = [:namespace] if ![:unscope] id = args.shift if [:on].to_sym == :member path = !match ? name.to_s : match.sub(/(:\w+)/, args[0]) if ![:root] [namespace, id, path].compact.join('/') end |