Sha256: 8a278b823102233af0bc845f22ec47edd0507cc2396a64ce17f4dfdbc76a3e6f

Contents?: true

Size: 915 Bytes

Versions: 45

Compression:

Stored size: 915 Bytes

Contents

module Shelly
  class Organization < Model
    attr_reader :name, :app_code_names

    def initialize(attributes = {})
      @name           = attributes["name"]
      @app_code_names = attributes["app_code_names"]
    end

    def apps
      app_code_names.map do |code_name|
        Shelly::App.new(code_name)
      end
    end

    def memberships
      @members ||= Array(shelly.members(name)).
        sort_by { |c| c["email"] }
    end

    def owners
      memberships.select { |c| c["owner"] } - inactive_members
    end

    def members
      memberships.select { |c| !c["owner"] } - inactive_members
    end

    def inactive_members
      memberships.select { |c| !c["active"] }
    end

    def send_invitation(email, owner)
      shelly.send_invitation(name, email, owner)
    end

    def delete_member(email)
      shelly.delete_member(name, email)
    end

    def to_s
      name
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
shelly-0.3.8 lib/shelly/organization.rb
shelly-0.3.7 lib/shelly/organization.rb
shelly-0.3.6 lib/shelly/organization.rb
shelly-0.3.5 lib/shelly/organization.rb
shelly-0.3.5.pre lib/shelly/organization.rb
shelly-0.3.4 lib/shelly/organization.rb
shelly-0.3.3 lib/shelly/organization.rb
shelly-0.3.2 lib/shelly/organization.rb
shelly-0.3.1 lib/shelly/organization.rb
shelly-0.3.0 lib/shelly/organization.rb
shelly-0.2.28 lib/shelly/organization.rb
shelly-0.2.27 lib/shelly/organization.rb
shelly-0.2.26 lib/shelly/organization.rb
shelly-0.2.25 lib/shelly/organization.rb
shelly-0.2.24 lib/shelly/organization.rb
shelly-0.2.23 lib/shelly/organization.rb
shelly-0.2.22 lib/shelly/organization.rb
shelly-0.2.21 lib/shelly/organization.rb
shelly-0.2.20 lib/shelly/organization.rb
shelly-0.2.19 lib/shelly/organization.rb