Sha256: 7a8fcab7193b18284f1ac72ae8db90568f07ab7983d1ef5af4078716fd4b1f9d

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

module Form
  extend ActiveSupport::Concern

  included do
    attr_accessor :_subtitle

    validates :_subtitle, invisible_captcha: true

    before_save :set_locale

    delegate :virtual?, :has_attachments?, :has_collections?, to: :class
  end

  class_methods do
    def virtual?
      false
    end

    def has_attachments?
      respond_to? :attachments
    end

    def has_collections?
      respond_to? :collections
    end

    def has_collections(*collections)
      define_singleton_method :collections do
        collections
      end

      delegate :collections, to: :class
    end
  end

  class << self
    def structure_models
      %w[
        Form::Structure
        Form::Field
        Form::Email
      ]
    end
  end

  private

  def set_locale
    if has_attribute?(:locale) && locale.nil?
      self.locale = I18n.locale
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_admin_cms-0.0.2 app/models/form.rb