1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

Rename ModelSupport to Decoratable

This commit is contained in:
Andrew Haines 2012-10-09 10:11:57 +01:00
parent 61e6027236
commit d06afda764
8 changed files with 12 additions and 12 deletions

View file

@ -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'

View file

@ -1,4 +1,4 @@
module Draper::ModelSupport
module Draper::Decoratable
extend ActiveSupport::Concern
def decorator(options = {})

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,5 +1,5 @@
class Product < ActiveRecord::Base
include Draper::ModelSupport
include Draper::Decoratable
def self.find_by_name(name)
@@dummy ||= Product.new