Sha256: c277edfee71e95cdb04231d9ca5a9b71611b365160b1fb604ea02160535d4714

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

# -*- coding: utf-8 -*-
class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  helper_method :standalone?, :raspberrypi?

  private

  # スタンドアローンモードかどうかを返す
  def standalone?
    return false if Rails.env == 'production'
    return true if Rails.env == 'standalone'

    if Rails.env != 'test' &&
        (ENV['SMALRUBY_EDITOR_STANDALONE_MODE'] ||
         File.exist?(Rails.root.join('tmp', 'standalone')))
      true
    else
      false
    end
  end

  # Raspberry Piかどうかを返す
  def raspberrypi?
    if Rails.env != 'test' &&
        (ENV['SMALRUBY_EDITOR_RASPBERRYPI_MODE'] ||
         File.exist?(Rails.root.join('tmp', 'raspberrypi')))
      true
    else
      RbConfig::CONFIG['arch'] == 'armv6l-linux-eabihf'
    end
  end

  def check_whether_standalone
    unless standalone?
      fail "#{self.class.name}##{action_name}はstandaloneモードのみの機能です"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
smalruby-editor-0.1.15-x86-mingw32 app/controllers/application_controller.rb
smalruby-editor-0.1.15 app/controllers/application_controller.rb
smalruby-editor-0.1.14-x86-mingw32 app/controllers/application_controller.rb
smalruby-editor-0.1.14 app/controllers/application_controller.rb
smalruby-editor-0.1.13-x86-mingw32 app/controllers/application_controller.rb
smalruby-editor-0.1.13 app/controllers/application_controller.rb