Sha256: aeb61040eb62706b6b019c13d8fa3cb537f143bb3022abcaaff99b00c8dd5340

Contents?: true

Size: 1.24 KB

Versions: 8

Compression:

Stored size: 1.24 KB

Contents

require 'singleton'
require 'yaml'

require 'kentouzu/config'
require 'kentouzu/controller'
require 'kentouzu/has_drafts'
require 'kentouzu/draft'

module Kentouzu
  def self.enabled=(value)
    Kentouzu.config.enabled = value
  end

  def self.enabled?
    !!Kentouzu.config.enabled
  end

  def self.enabled_for_controller=(value)
    drafts_store[:request_enabled_for_controller] = value
  end

  def self.enabled_for_controller?
    !!drafts_store[:request_enabled_for_controller]
  end

  def self.timestamp_field=(field_name)
    Kentouzu.config.timestamp_field = field_name
  end

  def self.timestamp_field
    Kentouzu.config.timestamp_field
  end

  def self.source=(value)
    drafts_store[:source] = value
  end

  def self.source
    drafts_store[:source]
  end

  def self.controller_info=(value)
    drafts_store[:controller_info] =  value
  end

  def self.controller_info
    drafts_store[:controller_info]
  end

  private

  def self.drafts_store
    Thread.current[:draft] ||= { :request_enabled_for_controller => true }
  end

  def self.config
    @@config ||= Kentouzu::Config.instance
  end
end

ActiveSupport.on_load(:active_record) do
  include Kentouzu::Model
end

ActiveSupport.on_load(:action_controller) do
  include Kentouzu::Controller
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kentouzu-0.1.2 lib/kentouzu.rb
kentouzu-0.1.1 lib/kentouzu.rb
kentouzu-0.1.0 lib/kentouzu.rb
kentouzu-0.0.13 lib/kentouzu.rb
kentouzu-0.0.12 lib/kentouzu.rb
kentouzu-0.0.11 lib/kentouzu.rb
kentouzu-0.0.10 lib/kentouzu.rb
kentouzu-0.0.9 lib/kentouzu.rb