class Object

Public Instance Methods

authenticate_any_role!(*roles) click to toggle source
# File lib/crosstie/templates/authorization/application_controller.rb, line 28
def authenticate_any_role! *roles
  return unless user_signed_in?
  unless current_user.has_any_role? *roles
    raise AuthenticationError, "#{current_user.name} not authenticated as any of #{roles.join(", ")}"
  end
end
authenticate_current_user!(user) click to toggle source
# File lib/crosstie/templates/authorization/application_controller.rb, line 17
def authenticate_current_user! user
  raise AuthorizationError unless current_user == user or current_user.system?
end
authenticate_role!(role, resource = nil) click to toggle source
# File lib/crosstie/templates/authorization/application_controller.rb, line 21
def authenticate_role! role, resource = nil
  return unless user_signed_in?
  unless current_user.has_role? role
    raise AuthenticationError, "#{current_user.name} not authenticated as a #{role} user"
  end
end
config() click to toggle source
# File lib/crosstie/base.rb, line 23
def config
  return @config if @config
  config_path = '/tmp/crosstie/config.yml'
  if File.exist? config_path
    @config = YAML.load(File.read(config_path))
    File.delete config_path
  else
    @config = {}
  end
  @config
end
git_commit(message) click to toggle source
# File lib/crosstie/base.rb, line 3
def git_commit message
  git add: '-A'
  git commit: "-a -m '#{message}'"
end
perform(task) click to toggle source
# File lib/crosstie/base.rb, line 16
def perform task
  eval File.read File.join root, "templates", "#{task}.rb"
rescue => e
  puts "error on performing #{task}"
  raise e
end
read_template(*path) click to toggle source
# File lib/crosstie/base.rb, line 12
def read_template *path
  File.read File.join root, "templates", *path
end
root() click to toggle source
# File lib/crosstie/base.rb, line 8
def root
  @root ||= File.expand_path File.dirname __FILE__
end