You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
『るびま』は、Ruby に関する技術記事はもちろんのこと、Rubyist へのインタビューやエッセイ、その他をお届けするウェブ雑誌です。 Rubyist Magazine について 『Rubyist Magazine』、略して『るびま』は、Rubyist の Rubyist による、Rubyist とそうでない人のためのウェブ雑誌です。 最新号 Rubyist Magazine 0064 号 バックナンバー Rubyist Magazine 0064 号 Rubyist Magazine 0063 号 Rubyist Magazine 0062 号 Kaigi on Rails 特集号 RubyKaigi Takeout 2020 特集号 Rubyist Magazine 0061 号 Rubyist Magazine 0060 号 RubyKaigi 2019 直前特集号 Rubyist
AASM - Ruby state machines ここを参考にしました。 https://github.com/aasm/aasm/blob/master/README.md https://github.com/aasm/aasm/blob/master/CHANGELOG.md ※2014年に本記事を投稿してから、細々と継続的にアクセスがあるようです。AASMの仕様は投稿当時と最新版でもそれほど変わっていないようですが、ご利用にあたっては必ず上記GitHubのREADMEとCHANELOGの確認をお願いします。 概要 AASMはRubyのclassに有限オートマトンを追加するライブラリ。2014年10月現在でも精力的に開発が進められている。以下の内容は gem version ~~~3.4.0~~~ 4.9.0 に準拠する。 http://techblog.heartrails.c
Stay Relevant and Grow Your Career in TechPremium ResultsPublish articles on SitePointDaily curated jobsLearning PathsDiscounts to dev toolsStart Free Trial7 Day Free Trial. Cancel Anytime. Key Takeaways The Adapter Design Pattern in Ruby allows for greater flexibility and easier addition of new methods by separating implementations into modules, rather than using conditional branching. The Adapte
記念すべき「Rails Tips」第1回は、Decorator と Presenter について書きます。 Rails で Decorator/Presenter というと draper や active_decorator などの実績のある有名な gem パッケージが存在していて、それらを導入すれば話は簡単なのですが、本稿ではあえて Rails 標準の機能を用いて Decorator/Presenter を実現する方法を説明します。「車輪の再発明!」と言わないでください。自分で作ってみることによって Ruby や Rails の知識が深まり、様々な応用が利くようになります。実際のところ、そんなに複雑なものではありません。 Decorator とは 「Decorator」はソフトウェアデザインパターンの1つで、継承(inheritance)に代わるクラスの拡張手段です。 具体例で説明しまし
Photo by Flickr: HerryLawford's Photostream DraperはRailsのプレゼンテーション層の役割を担うgemです。 この記事では、Draperを通し、プレゼンテーション層の必要性や使い方を説明します。 動作確認 Ruby 2.2.1 Rails 4.2.0 Draper 1.4.0 目次 0. プレゼンテーション層の必要性 1. Draperのインストール方法 2. Draperの簡単な使い方 3. デコレーターインスタンスの作成 3.1. 単独のオブジェクトのデコレーター 3.2. コレクションの個々のオブジェクトのデコレーター 3.3. コレクション自身のデコレーター 3.4. 関連するオブジェクトのデコレーター 4. デコレータークラスの作成 4.1. デコレーター内でヘルパーメソッドへのアクセス 4.2. デコレーター内でモデルオブジェク
Railsで、モデルの内容をビューに出すときにちょっと加工するみたいな時、そのコードはどこに書けばいいんだ問題。 デザインパターンの一つにDecoratorパターンというのがあって、これを適用させるのが良いらしい。この用途ではactive_decoratorと並んで人気のgem、draperの説明がとてもわかりやすかった。 draperのREADMEで挙げられているのは、Articleという記事のモデルがあり、これの公開状態を表示させる機能を実装するという例だ。これを読み、なぜヘルパーメソッドやモデルに直に実装するんじゃだめなの?という疑問に対する答えを意訳していく。 ヘルパーメソッドを作る場合 ヘルパーメソッドで書くと、こうなる。 # app/helpers/articles_helper.rb def publication_status(article) if article.pub
Draperって何?Draperは、Model/Controller/View/Helperと異なる第4のレイヤを提供するGemです。 この第4のレイヤは、海外では「Presenter」として分類されています。(正確にもう少し細かい分類があるらしいですが割愛♪) このレイヤを作るメリットは、 model/viewに余計なロジックを書かなくてすむ Helperのメソッドが使われている場所が不明という事態を防ぐ 日本ではPresenterレイヤでは、ActiveDecoratorというGemが有名です。ActiveDecoratorもほぼ同じことができます。 Draperの紹介Draperの説明ならRailsCastが一番わかり易かったです(説明は日本語に翻訳されています、動画は英語です)↓ #####286 Draper - RailsCasts 1年前の記事ですので、実際に動かしてみると少
前回、ステート・パターンをRubyで実装してみた。 簡潔さは力なり!Rubyでステートパターン(State Pattern)を実装する | Futurismo これを機に、ステート・マシンもちゃんと実装まで学んでおこうとおもう。 ステート・マシンとは、システムの振る舞いの仕組み。 <p> ステートマシン図とは、それをUML記法で表したもの。 </p> <ul class="org-ul"> <li> <a href="https://ja.wikipedia.org/wiki/%E6%9C%89%E9%99%90%E3%82%AA%E3%83%BC%E3%83%88%E3%83%9E%E3%83%88%E3%83%B3">有限オートマトン - Wikipedia</a> </li> </ul> ステート・マシンの構成要素は以下のとおり。 <ul class="org-ul"> <li> 状
はじめに ここ一年くらいずっと Rails の何がダメでどうすれば良くなるのかを考えていました。 Rails を使ってそれなりの規模のアプリケーションを作ったことがある人なら、メンテナンスのしづらさを感じたことがあるのではないでしょうか。 メンテナンスの問題は Rails 以外の開発でも発生することですが、実のところメンテナンスしやすいアプリケーションはどうすれば作れるのでしょうか? この難問に対して私も答えを持っていませんが、考え続けています。 少なくとも、 Rails Way や Rails Tutorial をベースにしたアプリケーション開発は、業務で用いるには簡単すぎるように思います。 「レールに乗る」という言葉がありますが、私は考え方を変えました。 Rails は規模の大きいフレームワークですが、土台に過ぎません。 Rails Way の設計方針は小規模な開発では有効ですが、規模
Plugin architecture is known as a technique that brings extensibility to a program. Ruby has good language features for plugins. RubyGems.org is an excellent platform for plugin distribution. However, creating plugin architecture is not as easy as writing code without it: plugin loader, packaging, loosely-coupled API, and performance. Loading two versions of a gem is a unsolved challenge that is s
06 September 2006 Decorator Pattern with Ruby in 8 lines The Decorator Pattern is a design pattern that enables you to dynamically wrap behaviour around an existing object at runtime. It is especially useful when an object can have many variables that can be combined in different ways, which in turn affect it’s behaviour. This small, simple implementation of the decorator pattern in Ruby sums up w
Our Services Think Big. For as long as we can remember, we’ve defied expectations and embraced the insurmountable, and we’re still just getting warmed up. So bring us the impossible, and let’s leave the simple to everyone else. You’ll find us out front polishing the corners of the bleeding edge. Learn more Large Scale Web & CMS Large Scale Web & CMS. As a Drupal partner with demonstrated success w
Singleton is perhaps the most hated of all programming patterns. You can read some of the reasons for this in Why Singletons are Evil. But, I think it has some good usages. I will start by describing what a singleton pattern is, walk through different ways of implementing it in Ruby, and point to how it’s used in Rails. Singleton is a design pattern that restricts instantiation of a class to only
Rubyを勉強する上で役立つ情報源をまとめてみました。まだ仕入れていない情報源があれば価値がある記事なんじゃないかと思います。 書籍 Everyday Rails - RSpecによるRailsテスト入門 Rubyでテストコードを書くときは多くの人がRspecを使っていると思いますが、そのRSpecを学ぶ上で実用的な書き方が学べます。実践で頑強なプログラミングを書けるようになり、チームの人たちも安心して仕事を任せてもらえます。 メタプログラミングRuby Ruby力を高める上で必要な知識がメタプログラミングです。コードを読むのにも書くのにも知っているかどうかで大きく影響します。これを読みきった頃には中級者に達していると言っても良いでしょう。 パーフェクトRuby ここまで学んだ知識の穴埋めをしてくれるでしょう。実践力向上に役立ちます。 パーフェクトRubyOnRails Rubyを使う上で
In computer science, a mutator method is a method used to control changes to a variable. They are also widely known as setter methods. Often a setter is accompanied by a getter, which returns the value of the private member variable. They are also known collectively as accessors. The mutator method is most often used in object-oriented programming, in keeping with the principle of encapsulation. A
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く