lib/aptible/rails/controller.rb in aptible-rails-0.4.1 vs lib/aptible/rails/controller.rb in aptible-rails-0.4.2
- old
+ new
@@ -6,11 +6,11 @@
module Controller
extend ActiveSupport::Concern
included do
helper_method :current_user, :current_organization, :user_url,
- :organization_url
+ :organization_url, :criterion_by_handle
end
def current_user
return unless current_user_url
@current_user ||= Aptible::Auth::User.find_by_url(current_user_url,
@@ -93,9 +93,17 @@
"#{dashboard_url}/organizations/#{id}"
end
def user_url(id = current_user.id)
"#{dashboard_url}/users/#{id}"
+ end
+
+ def criterion_by_handle(handle)
+ Aptible::Gridiron::Criterion.where(
+ handle: handle.to_s,
+ token: service_token,
+ organization: current_organization
+ ).first
end
end
end
end