Sha256: a5d8e83f37f4034546444f077da5a455aef6c2bf2a7867583dea8fc84137ada1

Contents?: true

Size: 986 Bytes

Versions: 21

Compression:

Stored size: 986 Bytes

Contents

class Dorsale::UserScope
  attr_reader :user

  def initialize(user)
    @user = user
  end

  # Common

  def colleagues(context = nil)
    User.all
  end

  def comments
    Dorsale::Comment.all
  end

  # Flyboy

  def folders
    Dorsale::Flyboy::Folder.all
  end

  def new_folder(*args)
    folders.new(*args)
  end

  def tasks
    Dorsale::Flyboy::Task.all
  end

  def new_task(*args)
    tasks.new(*args)
  end

  # CustomerVault

  def individuals
    Dorsale::CustomerVault::Individual.all
  end

  def new_individual(*args)
    individuals.new(*args)
  end

  def corporations
    Dorsale::CustomerVault::Corporation.all
  end

  def new_corporation(*args)
    corporations.new(*args)
  end

  def people
    (individuals + corporations).sort_by { |e| e.name.downcase }
  end

  # ExpenseGun

  def expenses
    Dorsale::ExpenseGun::Expense.all
  end

  def new_expense(attributes = {})
    attributes = attributes.merge(user: user)
    expenses.new(attributes)
  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
dorsale-2.4.1 spec/dummy/app/models/dorsale/user_scope.rb