From d06afda764c18a0e666f47c1ffe47d3b1aab899b Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Tue, 9 Oct 2012 10:11:57 +0100 Subject: [PATCH] Rename ModelSupport to Decoratable --- lib/draper.rb | 2 +- lib/draper/{model_support.rb => decoratable.rb} | 2 +- lib/draper/decorator.rb | 2 +- lib/draper/railtie.rb | 2 +- spec/draper/decorator_spec.rb | 2 +- spec/draper/model_support_spec.rb | 10 +++++----- spec/support/samples/namespaced_product.rb | 2 +- spec/support/samples/product.rb | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) rename lib/draper/{model_support.rb => decoratable.rb} (94%) diff --git a/lib/draper.rb b/lib/draper.rb index c3e83a9..4294720 100644 --- a/lib/draper.rb +++ b/lib/draper.rb @@ -5,7 +5,7 @@ require 'draper/system' require 'draper/active_model_support' require 'draper/decorator' require 'draper/lazy_helpers' -require 'draper/model_support' +require 'draper/decoratable' require 'draper/helper_support' require 'draper/view_context' require 'draper/collection_decorator' diff --git a/lib/draper/model_support.rb b/lib/draper/decoratable.rb similarity index 94% rename from lib/draper/model_support.rb rename to lib/draper/decoratable.rb index 5bbb78a..7fa32f2 100644 --- a/lib/draper/model_support.rb +++ b/lib/draper/decoratable.rb @@ -1,4 +1,4 @@ -module Draper::ModelSupport +module Draper::Decoratable extend ActiveSupport::Concern def decorator(options = {}) diff --git a/lib/draper/decorator.rb b/lib/draper/decorator.rb index f9d228f..1b9f904 100755 --- a/lib/draper/decorator.rb +++ b/lib/draper/decorator.rb @@ -49,7 +49,7 @@ module Draper def self.decorates(input, options = {}) self.model_class = options[:class] || options[:class_name] || input.to_s.camelize self.model_class = model_class.constantize if model_class.respond_to?(:constantize) - model_class.send :include, Draper::ModelSupport + model_class.send :include, Draper::Decoratable define_method(input){ @model } end diff --git a/lib/draper/railtie.rb b/lib/draper/railtie.rb index 04d35fa..c42522a 100755 --- a/lib/draper/railtie.rb +++ b/lib/draper/railtie.rb @@ -36,7 +36,7 @@ module Draper initializer "draper.extend_active_record_base" do |app| ActiveSupport.on_load(:active_record) do - self.send(:include, Draper::ModelSupport) + self.send(:include, Draper::Decoratable) end end diff --git a/spec/draper/decorator_spec.rb b/spec/draper/decorator_spec.rb index fa27ef3..71f7805 100755 --- a/spec/draper/decorator_spec.rb +++ b/spec/draper/decorator_spec.rb @@ -279,7 +279,7 @@ describe Draper::Decorator do context 'the decorated model' do it 'receives the mixin' do - source.class.ancestors.include?(Draper::ModelSupport) + source.class.ancestors.include?(Draper::Decoratable) end it 'includes ActiveModel support' do diff --git a/spec/draper/model_support_spec.rb b/spec/draper/model_support_spec.rb index d1791fe..9a3bf99 100644 --- a/spec/draper/model_support_spec.rb +++ b/spec/draper/model_support_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Draper::ModelSupport do +describe Draper::Decoratable do subject { Product.new } describe '#decorator' do @@ -17,8 +17,8 @@ describe Draper::ModelSupport do end end - describe Draper::ModelSupport::ClassMethods do - shared_examples_for "a call to Draper::ModelSupport::ClassMethods#decorate" do + describe Draper::Decoratable::ClassMethods do + shared_examples_for "a call to Draper::Decoratable::ClassMethods#decorate" do subject { klass.limit } its(:decorate) { should be_kind_of(Draper::CollectionDecorator) } @@ -36,13 +36,13 @@ describe Draper::ModelSupport do describe '#decorate - decorate collections of AR objects' do let(:klass) { Product } - it_should_behave_like "a call to Draper::ModelSupport::ClassMethods#decorate" + it_should_behave_like "a call to Draper::Decoratable::ClassMethods#decorate" end describe '#decorate - decorate collections of namespaced AR objects' do let(:klass) { Namespace::Product } - it_should_behave_like "a call to Draper::ModelSupport::ClassMethods#decorate" + it_should_behave_like "a call to Draper::Decoratable::ClassMethods#decorate" end end end diff --git a/spec/support/samples/namespaced_product.rb b/spec/support/samples/namespaced_product.rb index 1c6ed7e..29d576c 100644 --- a/spec/support/samples/namespaced_product.rb +++ b/spec/support/samples/namespaced_product.rb @@ -2,7 +2,7 @@ require './spec/support/samples/product' module Namespace class Product < ActiveRecord::Base - include Draper::ModelSupport + include Draper::Decoratable def self.first @@first ||= Namespace::Product.new diff --git a/spec/support/samples/product.rb b/spec/support/samples/product.rb index a2f73ec..7f1d06d 100644 --- a/spec/support/samples/product.rb +++ b/spec/support/samples/product.rb @@ -1,5 +1,5 @@ class Product < ActiveRecord::Base - include Draper::ModelSupport + include Draper::Decoratable def self.find_by_name(name) @@dummy ||= Product.new