Class: Pageflow::Widget

Inherits:
ApplicationRecord show all
Includes:
SerializedConfiguration
Defined in:
app/models/pageflow/widget.rb

Defined Under Namespace

Classes: Resolver

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializedConfiguration

#configuration

Instance Attribute Details

#widget_typeObject

Returns the value of attribute widget_type.



9
10
11
# File 'app/models/pageflow/widget.rb', line 9

def widget_type
  @widget_type
end

Class Method Details

.batch_update!(widgets_attributes) ⇒ Object



28
29
30
31
32
# File 'app/models/pageflow/widget.rb', line 28

def self.batch_update!(widgets_attributes)
  widgets_attributes.each do |attributes|
    find_or_initialize_by(role: attributes[:role]).update!(attributes)
  end
end

.copy_all_to(subject) ⇒ Object



22
23
24
25
26
# File 'app/models/pageflow/widget.rb', line 22

def self.copy_all_to(subject)
  all.each do |widget|
    widget.copy_to(subject)
  end
end

.resolve(config, options = {}) ⇒ Object



34
35
36
# File 'app/models/pageflow/widget.rb', line 34

def self.resolve(config, options = {})
  Resolver.new(config, options).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

#matches?(options) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'app/models/pageflow/widget.rb', line 17

def matches?(options)
  enabled_for_scope?(options[:scope]) &&
    for_insert_point?(options.fetch(:insert_point, :any))
end