Class: Pageflow::Widget
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Pageflow::Widget
- Includes:
- SerializedConfiguration
- Defined in:
- app/models/pageflow/widget.rb
Defined Under Namespace
Classes: Resolver
Instance Attribute Summary collapse
-
#widget_type ⇒ Object
Returns the value of attribute widget_type.
Class Method Summary collapse
- .batch_update!(widgets_attributes) ⇒ Object
- .copy_all_to(subject) ⇒ Object
- .resolve(config, options = {}) ⇒ Object
Instance Method Summary collapse
Methods included from SerializedConfiguration
Instance Attribute Details
#widget_type ⇒ Object
Returns the value of attribute widget_type.
9 10 11 |
# File 'app/models/pageflow/widget.rb', line 9 def end |
Class Method Details
.batch_update!(widgets_attributes) ⇒ Object
33 34 35 36 37 |
# File 'app/models/pageflow/widget.rb', line 33 def self.batch_update!() .each do |attributes| find_or_initialize_by(role: attributes[:role]).update!(attributes) end end |
.copy_all_to(subject) ⇒ Object
27 28 29 30 31 |
# File 'app/models/pageflow/widget.rb', line 27 def self.copy_all_to(subject) all.each do || .copy_to(subject) end end |
.resolve(config, options = {}) ⇒ Object
39 40 41 |
# File 'app/models/pageflow/widget.rb', line 39 def self.resolve(config, = {}) Resolver.new(config, ).result end |
Instance Method Details
#copy_to(subject) ⇒ Object
11 12 13 14 15 |
# File 'app/models/pageflow/widget.rb', line 11 def copy_to(subject) record = dup record.subject = subject record.save! end |
#enabled?(options) ⇒ Boolean
17 18 19 20 21 22 23 24 25 |
# File 'app/models/pageflow/widget.rb', line 17 def enabled?() if [:scope] == :editor .enabled_in_editor? elsif [:scope] == :preview .enabled_in_preview? else true end end |