Module: Draftsman
- Defined in:
- lib/draftsman.rb,
lib/draftsman/model.rb,
lib/draftsman/config.rb,
lib/draftsman/version.rb,
lib/draftsman/frameworks/rails.rb,
lib/draftsman/serializers/json.rb,
lib/draftsman/serializers/yaml.rb,
lib/draftsman/frameworks/sinatra.rb,
lib/generators/draftsman/install_generator.rb
Overview
Draftsman’s module methods can be called in both models and controllers.
Defined Under Namespace
Modules: Model, Rails, Serializers, Sinatra Classes: Config, Draft, InstallGenerator
Constant Summary collapse
- VERSION =
'0.3.6'
Class Method Summary collapse
-
.active_record_protected_attributes? ⇒ Boolean
Returns whether or not ActiveRecord is configured to require mass assignment whitelisting via ‘attr_accessible`.
-
.controller_info ⇒ Object
Returns any information from the controller that you want Draftsman to store.
-
.controller_info=(value) ⇒ Object
Sets any information from the controller that you want Draftsman to store.
-
.draft_class_name ⇒ Object
Returns default class name used for drafts.
-
.draft_class_name=(class_name) ⇒ Object
Sets default class name to use for drafts.
-
.serializer ⇒ Object
Returns serializer to use for ‘object`, `object_changes`, and `previous_draft` columns.
-
.serializer=(value) ⇒ Object
Sets serializer to use for ‘object`, `object_changes`, and `previous_draft` columns.
-
.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.
-
.whodunnit ⇒ Object
Returns who is reponsible for any changes that occur.
-
.whodunnit=(value) ⇒ Object
Sets who is responsible for any changes that occur.
Class Method Details
.active_record_protected_attributes? ⇒ Boolean
Returns whether or not ActiveRecord is configured to require mass assignment whitelisting via ‘attr_accessible`.
11 12 13 |
# File 'lib/draftsman.rb', line 11 def self.active_record_protected_attributes? @active_record_protected_attributes ||= ActiveRecord::VERSION::STRING.to_f < 4.0 || defined?(ProtectedAttributes) end |
.controller_info ⇒ Object
Returns any information from the controller that you want Draftsman to store.
See ‘Draftsman::Controller#info_for_draftsman`.
18 19 20 |
# File 'lib/draftsman.rb', line 18 def self.controller_info draftsman_store[:controller_info] end |
.controller_info=(value) ⇒ Object
Sets any information from the controller that you want Draftsman to store. By default, this is set automatically by a before filter.
24 25 26 |
# File 'lib/draftsman.rb', line 24 def self.controller_info=(value) draftsman_store[:controller_info] = value end |
.draft_class_name ⇒ Object
Returns default class name used for drafts.
29 30 31 |
# File 'lib/draftsman.rb', line 29 def self.draft_class_name draftsman_store[:draft_class_name] end |
.draft_class_name=(class_name) ⇒ Object
Sets default class name to use for drafts.
34 35 36 |
# File 'lib/draftsman.rb', line 34 def self.draft_class_name=(class_name) draftsman_store[:draft_class_name] = class_name end |
.serializer ⇒ Object
Returns serializer to use for ‘object`, `object_changes`, and `previous_draft` columns.
49 50 51 |
# File 'lib/draftsman.rb', line 49 def self.serializer Draftsman.config.serializer end |
.serializer=(value) ⇒ Object
Sets serializer to use for ‘object`, `object_changes`, and `previous_draft` columns.
54 55 56 |
# File 'lib/draftsman.rb', line 54 def self.serializer=(value) Draftsman.config.serializer = value end |
.timestamp_field ⇒ Object
Returns the field which records when a draft was created.
44 45 46 |
# File 'lib/draftsman.rb', line 44 def self. Draftsman.config. end |
.timestamp_field=(field_name) ⇒ Object
Set the field which records when a draft was created.
39 40 41 |
# File 'lib/draftsman.rb', line 39 def self.(field_name) Draftsman.config. = field_name end |
.whodunnit ⇒ Object
Returns who is reponsible for any changes that occur.
59 60 61 |
# File 'lib/draftsman.rb', line 59 def self.whodunnit draftsman_store[:whodunnit] end |
.whodunnit=(value) ⇒ Object
Sets who is responsible for any changes that occur. You would normally use this in a migration or on the console, when working with models directly. In a controller, it is set automatically to the ‘current_user`.
67 68 69 |
# File 'lib/draftsman.rb', line 67 def self.whodunnit=(value) draftsman_store[:whodunnit] = value end |