Class: LeanCloud::Route
- Inherits:
-
Object
- Object
- LeanCloud::Route
- Defined in:
- lib/lean_cloud/route.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#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, &block) ⇒ Route
constructor
A new instance of Route.
- #url(*args) ⇒ Object
Constructor Details
#initialize(name, options, match = false, &block) ⇒ Route
Returns a new instance of Route.
4 5 6 7 8 9 10 11 |
# File 'lib/lean_cloud/route.rb', line 4 def initialize(name, , match=false, &block) [:on] ||= :collection @name = name @request = [:via] ||= :get @match = match @options = @block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
3 4 5 |
# File 'lib/lean_cloud/route.rb', line 3 def block @block end |
#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 @options 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
13 14 15 16 17 18 |
# File 'lib/lean_cloud/route.rb', line 13 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].to_s) if ![:root] [namespace, id, path].compact.join('/') end |