Class: Hippo::API::Handlers::Tenant

Inherits:
ControllerBase show all
Defined in:
lib/hippo/api/handlers/tenant.rb

Constant Summary collapse

PUBLIC_ATTRS =
%w{slug name}

Instance Attribute Summary

Attributes inherited from ControllerBase

#data, #model, #params

Instance Method Summary collapse

Methods inherited from ControllerBase

#initialize

Methods included from FormattedReply

#json_status_str, #record_active_record_errors, #records_for_reply, #std_api_reply

Constructor Details

This class inherits a constructor from Hippo::API::ControllerBase

Instance Method Details

#createObject

isn’t really a create, but FE will think it’s creating because we don’t expose the id



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hippo/api/handlers/tenant.rb', line 11

def create
    tenant = Hippo::Tenant.current
    tenant.assign_attributes(data.slice(*PUBLIC_ATTRS))
    success = tenant.save
    if success && tenant.slug_previously_changed?
        Hippo::Tenant.system.perform do
            Hippo::Templates::TenantChange.create(tenant).deliver
        end
    end
    std_api_reply(:update, tenant,
                  only: PUBLIC_ATTRS,
                  success: success)
end

#showObject



6
7
8
# File 'lib/hippo/api/handlers/tenant.rb', line 6

def show
    std_api_reply(:retrieve, Hippo::Tenant.current, only: PUBLIC_ATTRS)
end