Class: DiscourseSubscriptionClient::AdminController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- DiscourseSubscriptionClient::AdminController
show all
- Defined in:
- app/controllers/discourse_subscription_client/admin_controller.rb
Instance Method Summary
collapse
Instance Method Details
#ensure_can_manage_subscriptions ⇒ Object
22
23
24
|
# File 'app/controllers/discourse_subscription_client/admin_controller.rb', line 22
def ensure_can_manage_subscriptions
Guardian.new(current_user).ensure_can_manage_subscriptions!
end
|
#failed_json ⇒ Object
26
27
28
|
# File 'app/controllers/discourse_subscription_client/admin_controller.rb', line 26
def failed_json
{ failed: "FAILED" }
end
|
#index ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'app/controllers/discourse_subscription_client/admin_controller.rb', line 8
def index
respond_to do |format|
format.html do
render :index
end
format.json do
render_json_dump(
authorized_supplier_count: SubscriptionClientSupplier.authorized.count,
resource_count: SubscriptionClientResource.count
)
end
end
end
|
#render_json_dump(json) ⇒ Object
42
43
44
|
# File 'app/controllers/discourse_subscription_client/admin_controller.rb', line 42
def render_json_dump(json)
render json: json, status: 200
end
|
#render_serialized(objects, serializer, opts = {}) ⇒ Object
34
35
36
|
# File 'app/controllers/discourse_subscription_client/admin_controller.rb', line 34
def render_serialized(objects, serializer, opts = {})
render_json_dump(serialize_data(objects, serializer, opts))
end
|
#serialize_data(objects, serializer, opts = {}) ⇒ Object
38
39
40
|
# File 'app/controllers/discourse_subscription_client/admin_controller.rb', line 38
def serialize_data(objects, serializer, opts = {})
ActiveModel::ArraySerializer.new(objects.to_a, opts.merge(each_serializer: serializer)).as_json
end
|
#success_json ⇒ Object
30
31
32
|
# File 'app/controllers/discourse_subscription_client/admin_controller.rb', line 30
def success_json
{ success: "OK" }
end
|