Sha256: e86daa72aca83b68808a8b73829978ce4051a5c806e7f3d130d53949e3cfd231

Contents?: true

Size: 1.04 KB

Versions: 50

Compression:

Stored size: 1.04 KB

Contents

module Shelly
  class Organization < Model
    attr_accessor :name, :app_code_names, :redeem_code

    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 create
      attributes = {:name => name, :redeem_code => redeem_code}
      shelly.create_organization(attributes)
    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

50 entries across 50 versions & 1 rubygems

Version Path
shelly-0.5.2 lib/shelly/organization.rb
shelly-0.5.1 lib/shelly/organization.rb
shelly-0.5.0 lib/shelly/organization.rb
shelly-0.4.42 lib/shelly/organization.rb
shelly-0.4.41 lib/shelly/organization.rb
shelly-0.4.40 lib/shelly/organization.rb
shelly-0.4.39 lib/shelly/organization.rb
shelly-0.4.38 lib/shelly/organization.rb
shelly-0.4.37 lib/shelly/organization.rb
shelly-0.4.36 lib/shelly/organization.rb
shelly-0.4.35 lib/shelly/organization.rb
shelly-0.4.34 lib/shelly/organization.rb
shelly-0.4.33 lib/shelly/organization.rb
shelly-0.4.32 lib/shelly/organization.rb
shelly-0.4.31 lib/shelly/organization.rb
shelly-0.4.30 lib/shelly/organization.rb
shelly-0.4.29 lib/shelly/organization.rb
shelly-0.4.29.pre lib/shelly/organization.rb
shelly-0.4.28 lib/shelly/organization.rb
shelly-0.4.28.pre2 lib/shelly/organization.rb