Socket
Book a DemoInstallSign in
Socket

padrino-decorator

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

padrino-decorator

0.0.4
bundlerRubygems
Version published
Maintainers
1
Created
Source

Padrino Decorator

padrino-decorator is a gem for Padrino.
Adds an object-oriented layer of presentation logic to your Padrino application.

Build Status Code Climate Coverage Status Dependency Status

Installation

Note: Version 0.0.3 or later work with Padrino 0.12.3 later.

Add the following to your Gemfile:

gem 'padrino-decorator'

And then execute:

$ bundle

Decorator Generator

Padrino provides generator support for quickly creating new decorators within your Padrino application. Note that the decorator tests are generated specifically tailored towards the testing framework chosen during application generation.

Very important to note that decorator generators are intended primarily to work within applications created through the Padrino application generator and that follow Padrino conventions.

Using the decorator generator is as simple as:

$ padrino-gen decorator User
OptionsDefaultAliasesDescription
root.-rspecify the root destination path
app/app-aspecify the application
destroyfalse-dremoves all generated files
namespace-nspecify the name space of your padrino project

Examples

# app/controllers/posts.rb
SampleProject::App.controllers :posts do

  get :index do
    source = Post.all
    @posts = decorate(source)
    render 'posts/index'
  end

  get :show, with: :id do
    source = Post.find(params[:id])
    @post = decorate(source)
    # or
    @post = PostDecorator.new(source, context: self)
    render 'posts/show'
  end

end

# app/decorators/post_decorator.rb
class PostDecorator < Padrino::Decorator::Base
  context SampleProject::App

  def formated_body
    h.simple_format(object.body)
  end

end

# app/views/posts/show.slim
h1 = @post.title
div
  = @post.formated_body

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Copyright (c) 2013 Takeshi Yabe. See LICENSE for details.

FAQs

Package last updated on 05 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.