Class: Para::Component::Base

Inherits:
ApplicationRecord show all
Defined in:
app/models/para/component/base.rb

Direct Known Subclasses

Resource, Settings

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

with_belongs_to_optional_option_if_needed

Class Method Details

.configurable_on(key, _options = {}) ⇒ Object



13
14
15
# File 'app/models/para/component/base.rb', line 13

def self.configurable_on(key, _options = {})
  store_accessor(:configuration, key)
end

.model_nameObject



60
61
62
# File 'app/models/para/component/base.rb', line 60

def self.model_name
  @model_name ||= ModelName.new(self)
end

.register(name, component) ⇒ Object



8
9
10
11
# File 'app/models/para/component/base.rb', line 8

def self.register(name, component)
  self.component_name = name
  Para::Component.registered_components[name] = component
end

Instance Method Details

#default_form_actionsObject



64
65
66
# File 'app/models/para/component/base.rb', line 64

def default_form_actions
  %i[submit submit_and_edit submit_and_add_another cancel]
end

#exportable?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/models/para/component/base.rb', line 48

def exportable?
  false
end

#history?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'app/models/para/component/base.rb', line 56

def history?
  false
end


41
42
43
44
45
46
# File 'app/models/para/component/base.rb', line 41

def main_navigation_name
  ::I18n.t(
    "components.main_navigation.#{identifier}",
    default: name
  )
end

#nameObject



34
35
36
37
38
39
# File 'app/models/para/component/base.rb', line 34

def name
  read_attribute(:name) || ::I18n.t(
    "components.component.#{identifier}",
    default: identifier.humanize
  )
end

#subclassable?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'app/models/para/component/base.rb', line 52

def subclassable?
  false
end

#to_paramObject



68
69
70
# File 'app/models/para/component/base.rb', line 68

def to_param
  slug
end

#update_with(attributes) ⇒ Object

This method is used by the components configuration system to assign updated attributes from the config file to the component.

This is meant to be overriden by components that have to define specific behavior, like for the Crud component



78
79
80
# File 'app/models/para/component/base.rb', line 78

def update_with(attributes)
  assign_attributes(attributes)
end