Sha256: fd5f300e8e9736a89cdfbb48dda0302a1c5e8260c9f28624aa83e45c36d99851

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module Stimul8
  module Component
    extend ActiveSupport::Concern
    require "stimul8/component/storage"
    require "stimul8/component/core"
    require "stimul8/component/models"
    require "stimul8/component/actions"
    require "stimul8/component/create"

    included do
      include Stimul8::Component::Storage
      include Stimul8::Component::Core
      include Stimul8::Component::Models
      include Stimul8::Component::Actions
      include Stimul8::Component::Create
    end

    class << self
      def recreate component_class, component_id, context: nil
        component_class.constantize.new(component_id: component_id, context: context)
      end

      def component(component_class, properties = {}, &contents)
        component_class = "#{component_class.to_s.classify}Component"
        component = component_class.constantize.new(**properties, &contents)
        component.to_html.html_safe
      end

      alias_method :c, :component
    end

    class NotFound < Stimul8::Error
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stimul8-0.1.0 lib/stimul8/component.rb