Sha256: df25f44f2860a127e3b8d8abf296b08da6e24cdd19b3a5ffd6ee6e7469015e26

Contents?: true

Size: 542 Bytes

Versions: 5

Compression:

Stored size: 542 Bytes

Contents

module ExpressTemplates
  module Components
    class All < Container

      has_argument :id, "Name of the collection", as: :collection_name, type: :symbol

      contains -> (&block) {
        prepended
        collection.each do |item|
          assigns[member_name.to_sym] = item
          block.call(self) if block
        end
        appended
      }

      def member_name
        config[:collection_name].to_s.singularize.to_sym
      end

      def collection
        self.send(config[:collection_name])
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
express_admin-1.6.3 vendor/gems/express_templates/lib/express_templates/components/all.rb
express_templates-0.11.1 lib/express_templates/components/all.rb
express_admin-1.6.2 vendor/gems/express_templates/lib/express_templates/components/all.rb
express_admin-1.6.1 vendor/gems/express_templates/lib/express_templates/components/all.rb
express_templates-0.11.0 lib/express_templates/components/all.rb