Sha256: 158d7b9e62646b5eb89b6a26ae67bf23a03837a951dccedcddfe1eba65b363d2

Contents?: true

Size: 535 Bytes

Versions: 4

Compression:

Stored size: 535 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] = 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

4 entries across 4 versions & 2 rubygems

Version Path
express_admin-1.6.0 vendor/gems/express_templates/lib/express_templates/components/all.rb
express_templates-0.10.1 lib/express_templates/components/all.rb
express_admin-1.5.0 vendor/gems/express_templates/lib/express_templates/components/all.rb
express_admin-1.4.11 vendor/gems/express_templates/lib/express_templates/components/all.rb