Sha256: 8da43aa0ad46a85ea327ee95c78fba74401ae7a8bfaf8398ae6163651857fa7d

Contents?: true

Size: 1.57 KB

Versions: 10

Compression:

Stored size: 1.57 KB

Contents

module Mumuki::Domain::Helpers::Organization
  extend ActiveSupport::Concern
  include Mumukit::Platform::Notifiable

  included do
    delegate *Mumuki::Domain::Organization::Theme.accessors, to: :theme
    delegate *Mumuki::Domain::Organization::Settings.accessors, :private?, :login_settings, :in_preparation?, :disabled?, to: :settings
    delegate *Mumuki::Domain::Organization::Profile.accessors, :locale_json, to: :profile
  end

  def platform_class_name
    :Organization
  end

  def slug
    Mumukit::Auth::Slug.join_s name
  end

  def central?
    name == 'central'
  end

  def test?
    name == 'test'
  end

  def base?
    name == 'base'
  end

  def switch!
    Mumukit::Platform::Organization.switch! self
  end

  def to_s
    name
  end

  def url_for(path)
    Mumukit::Platform.application.organic_url_for(name, path)
  end

  def url
    url_for '/'
  end

  def domain
    Mumukit::Platform.application.organic_domain(name)
  end

  def validate_active!
    raise Mumuki::Domain::DisabledOrganizationError if disabled?
    raise Mumuki::Domain::UnpreparedOrganizationError if in_preparation?
  end

  ## API Exposure

  def to_param
    name
  end

  ## Resource Hash

  module ClassMethods
    def current
      Mumukit::Platform::Organization.current
    end

    def parse(json)
      json
        .slice(:name)
        .merge(theme: Mumuki::Domain::Organization::Theme.parse(json[:theme]))
        .merge(settings: Mumuki::Domain::Organization::Settings.parse(json[:settings]))
        .merge(profile: Mumuki::Domain::Organization::Profile.parse(json[:profile]))
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
mumuki-domain-7.7.3 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-7.8.1 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-7.8.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-7.7.2 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-7.7.1 lib/mumuki/domain/helpers/organization.rb
mumuki-laboratory-7.7.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-cb7a9018bb94/lib/mumuki/domain/helpers/organization.rb
mumuki-laboratory-7.7.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-cb7a9018bb94/lib/mumuki/domain/helpers/organization.rb
mumuki-domain-7.7.0 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-7.6.1 lib/mumuki/domain/helpers/organization.rb
mumuki-domain-7.6.0 lib/mumuki/domain/helpers/organization.rb