Sha256: 710ddffe77bb451a8ea22fbfe4ef6e1dc7df4322844365617edd4714d4646ffb
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
module Para module Component class Base < ActiveRecord::Base self.table_name = 'para_components' class_attribute :component_name, :configurable_attributes def self.register(name, component) self.component_name = name Para::Component.registered_components[name] = component end extend FriendlyId friendly_id :name, use: [:slugged, :finders, :history] validates :identifier, :type, presence: true belongs_to :component_section, class_name: 'Para::ComponentSection' scope :ordered, -> { order(position: :asc) } def name read_attribute(:name) || I18n.t( "components.component.#{ identifier }", default: identifier.humanize ) end def exportable? false end def self.model_name @model_name ||= ModelName.new(self) end def self.configurable_on(key, options = {}) store_accessor(:configuration, key) configurable_attributes[key] = options end def self.configurable? configurable_attributes.length > 0 end def self.configurable_attributes @configurable_attributes ||= {} end def should_generate_new_friendly_id? slug.blank? || name_changed? end def default_form_actions [:submit, :submit_and_edit, :submit_and_add_another, :cancel] end end class ModelName < ActiveModel::Name def route_key super.gsub(/(para_|component_|_component$)/, '') end def singular_route_key super.gsub(/(para_|component_|_component$)/, '') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
para-0.4.0 | app/models/para/component/base.rb |