Skip to content

Commit

Permalink
Add subscription support
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave McNelis committed Feb 6, 2013
1 parent 5337677 commit b1df17a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/grape/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ def desc(description, options = {})
# Add tier to the next namespace or function.
def tier(tier, options = {})
tier = :any if tier == '*'
tier = tier.to_s.capitalize
tier = ['Basic','Enhanced','Premium','Any','None'].include?(tier) ? tier : 'None'
tier = tier.to_sym.downcase
tier = [:basic,:enhanced,:premium,:any,:none].include?(tier) ? tier : :none
@last_tier = options.merge(:tier => tier)
end

# Add level to the next namespace or function.
def level(level, options = {})
level = :any if level == '*'
level = level.to_s.capitalize
level = ['Account','Contact','Advisor','Advisory Firm','Segment','Bundle','Any','None'].include?(level) ? level : 'None'
level = level.to_sym.downcase
level = [:account,:contact,:advisor,:advisory_firm,:segment,:bundle,:any,:none].include?(level) ? level : :none
@last_level = options.merge(:level => level)
end

Expand Down
10 changes: 10 additions & 0 deletions lib/grape/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ def params
deep_merge(env['rack.routing_args'] || {})
end

# The minimum API tier
def tier
env["api.endpoint"].options.fetch(:route_options,{}).fetch(:tier,:any)
end

# The minimum API level
def level
env["api.endpoint"].options.fetch(:route_options,{}).fetch(:level,:any)
end

# A filtering method that will return a hash
# consisting only of keys that have been declared by a
# `params` statement.
Expand Down

0 comments on commit b1df17a

Please sign in to comment.