Class: Para::Component::Base

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/para/component/base.rb

Direct Known Subclasses

Resource, Settings

Class Method Summary collapse

Instance Method Summary collapse

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



46
47
48
# File 'app/models/para/component/base.rb', line 46

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



50
51
52
# File 'app/models/para/component/base.rb', line 50

def default_form_actions
  [:submit, :submit_and_edit, :submit_and_add_another, :cancel]
end

#exportable?Boolean

Returns:

  • (Boolean)


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

def exportable?
  false
end

#history?Boolean

Returns:

  • (Boolean)


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

def history?
  false
end

#nameObject



27
28
29
30
31
32
# File 'app/models/para/component/base.rb', line 27

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

#subclassable?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/para/component/base.rb', line 38

def subclassable?
  false
end

#to_paramObject



54
55
56
# File 'app/models/para/component/base.rb', line 54

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



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

def update_with(attributes)
  assign_attributes(attributes)
end