Skip to content

Commit

Permalink
fix(models_controller): mix up of private/public methods
Browse files Browse the repository at this point in the history
  • Loading branch information
paulRbr committed Sep 5, 2014
1 parent 3e648f6 commit 9ebef18
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions lib/yodatra/models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ module Yodatra
# enable_search_on :name
class ModelsController < Sinatra::Base

# Generic route to target ONE resource
ONE_ROUTE =
%r{\A/([\w]+?)/([0-9]+)(?:/([\w]+?)/([0-9]+)){0,1}\Z}

# Generic route to target ALL resources
ALL_ROUTE =
%r{\A/([\w]+?)(?:/([0-9]+)/([\w]+?)){0,1}\Z}

# Search route
SEARCH_ROUTE =
%r{\A/([\w]+?)(?:/([0-9]+)/([\w]+?)){0,1}/search\Z}

before do
content_type 'application/json'
end
Expand Down Expand Up @@ -103,8 +115,6 @@ class ModelsController < Sinatra::Base
end

class << self
private

def model_name
self.name.split('::').last.gsub(/sController/, '')
end
Expand All @@ -113,8 +123,6 @@ def model
model_name.constantize
end

public

# This helper gives the ability to disable default root by specifying
# a list of routes to disable.
# @param *opts list of routes to disable (e.g. :create, :destroy)
Expand Down Expand Up @@ -158,18 +166,6 @@ def enable_search_on(*attributes)

private

# Generic route to target ONE resource
ONE_ROUTE =
%r{\A/([\w]+?)/([0-9]+)(?:/([\w]+?)/([0-9]+)){0,1}\Z}

# Generic route to target ALL resources
ALL_ROUTE =
%r{\A/([\w]+?)(?:/([0-9]+)/([\w]+?)){0,1}\Z}

# Search route
SEARCH_ROUTE =
%r{\A/([\w]+?)(?:/([0-9]+)/([\w]+?)){0,1}/search\Z}

# Defines a nested route or not and retrieves the correct resource (or resources)
# @param disables is the name to check if it was disabled
# @param &block to be yield with the retrieved resource
Expand Down

0 comments on commit 9ebef18

Please sign in to comment.