Module: Kentouzu
- Defined in:
- lib/kentouzu.rb,
lib/kentouzu/config.rb,
lib/kentouzu/version.rb,
lib/kentouzu/controller.rb,
lib/kentouzu/has_drafts.rb,
lib/generators/kentouzu/install_generator.rb
Defined Under Namespace
Modules: Controller, Model Classes: Config, InstallGenerator
Constant Summary collapse
- VERSION =
'0.2.4'
Class Method Summary collapse
-
.active_record_protected_attributes? ⇒ Boolean
Returns ‘true` if ActiveRecord requires mass assigned attributes to be whitelisted via `attr_accessible`, `false` otherwise.
-
.controller_info ⇒ Object
Returns any information from the controller that you want Kentouzu to store.
-
.controller_info=(value) ⇒ Object
Sets any information from the controller that you want Kentouzu to store.
-
.enabled=(value) ⇒ Object
Switches Kentouzu on or off globally.
-
.enabled? ⇒ Boolean
Returns ‘true` if Kentouzu is enabled globally, `false` otherwise.
-
.enabled_for_controller=(value) ⇒ Object
Switches Kentouzu on or off for the current request.
-
.enabled_for_controller? ⇒ Boolean
Returns ‘true` if Kentouzu is enabled for the current request, `false` otherwise.
-
.enabled_for_model(model, value) ⇒ Object
Switches Kentouzu on or off for the model for the current request.
-
.enabled_for_model?(model) ⇒ Boolean
Returns ‘true` if Kentouzu is enabled for the model for the current request, `false` otherwise.
-
.source ⇒ Object
Returns who is responsible for creating the draft.
-
.source=(value) ⇒ Object
Sets who is responsible for creating the draft.
-
.timestamp_field ⇒ Object
Returns the field which records when a draft was created.
-
.timestamp_field=(field_name) ⇒ Object
Set the field which records when a draft was created.
Class Method Details
.active_record_protected_attributes? ⇒ Boolean
Returns ‘true` if ActiveRecord requires mass assigned attributes to be whitelisted via `attr_accessible`, `false` otherwise.
73 74 75 |
# File 'lib/kentouzu.rb', line 73 def self.active_record_protected_attributes? @active_record_protected_attributes ||= ActiveRecord::VERSION::MAJOR < 4 || !!defined?(ProtectedAttributes) end |
.controller_info ⇒ Object
Returns any information from the controller that you want Kentouzu to store.
68 69 70 |
# File 'lib/kentouzu.rb', line 68 def self.controller_info drafts_store[:controller_info] end |
.controller_info=(value) ⇒ Object
Sets any information from the controller that you want Kentouzu to store.
63 64 65 |
# File 'lib/kentouzu.rb', line 63 def self.controller_info=(value) drafts_store[:controller_info] = value end |
.enabled=(value) ⇒ Object
Switches Kentouzu on or off globally.
10 11 12 |
# File 'lib/kentouzu.rb', line 10 def self.enabled=(value) Kentouzu.config.enabled = value end |
.enabled? ⇒ Boolean
Returns ‘true` if Kentouzu is enabled globally, `false` otherwise. Kentouzu is enabled by default.
16 17 18 |
# File 'lib/kentouzu.rb', line 16 def self.enabled? !!Kentouzu.config.enabled end |
.enabled_for_controller=(value) ⇒ Object
Switches Kentouzu on or off for the current request.
21 22 23 |
# File 'lib/kentouzu.rb', line 21 def self.enabled_for_controller=(value) drafts_store[:request_enabled_for_controller] = value end |
.enabled_for_controller? ⇒ Boolean
Returns ‘true` if Kentouzu is enabled for the current request, `false` otherwise.
26 27 28 |
# File 'lib/kentouzu.rb', line 26 def self.enabled_for_controller? !!drafts_store[:request_enabled_for_controller] end |
.enabled_for_model(model, value) ⇒ Object
Switches Kentouzu on or off for the model for the current request.
31 32 33 |
# File 'lib/kentouzu.rb', line 31 def self.enabled_for_model(model, value) drafts_store[:"enabled_for_#{model}"] = value end |
.enabled_for_model?(model) ⇒ Boolean
Returns ‘true` if Kentouzu is enabled for the model for the current request, `false` otherwise.
36 37 38 |
# File 'lib/kentouzu.rb', line 36 def self.enabled_for_model?(model) !!drafts_store.fetch(:"enabled_for_#{model}", true) end |
.source ⇒ Object
Returns who is responsible for creating the draft.
58 59 60 |
# File 'lib/kentouzu.rb', line 58 def self.source drafts_store[:source] end |
.source=(value) ⇒ Object
Sets who is responsible for creating the draft. Inside of a controller this will automatically be set to ‘current_user`. Outside of a controller it will need to be set manually.
53 54 55 |
# File 'lib/kentouzu.rb', line 53 def self.source=(value) drafts_store[:source] = value end |
.timestamp_field ⇒ Object
Returns the field which records when a draft was created.
46 47 48 |
# File 'lib/kentouzu.rb', line 46 def self. Kentouzu.config. end |
.timestamp_field=(field_name) ⇒ Object
Set the field which records when a draft was created.
41 42 43 |
# File 'lib/kentouzu.rb', line 41 def self.(field_name) Kentouzu.config. = field_name end |