Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Insert a hash of column details instead of column objects. Presenters…

… will handle their life cycle.
  • Loading branch information...
commit 522f83916dc1e2d01434d30a9a4705b13b6c9ed0 1 parent b77748e
@bobbytables authored
Showing with 6 additions and 12 deletions.
  1. +2 −2 lib/table_cloth/base.rb
  2. +4 −10 spec/lib/base_spec.rb
View
4 lib/table_cloth/base.rb
@@ -30,7 +30,7 @@ def column(*args, &block)
column_class = options.delete(:using) || Column
args.each do |name|
- add_column name, column_class.new(name, options)
+ add_column(class: column_class, options: options, name: name)
end
end
@@ -43,7 +43,7 @@ def columns
@columns
end
- def add_column(name, column)
+ def add_column(options)
@columns ||= {}
@columns[options[:name]] = options
end
View
14 spec/lib/base_spec.rb
@@ -33,22 +33,16 @@
subject.column(:name) { 'Wee' }
column = subject.columns[:name]
- expect(column.options[:proc]).to be_present
- expect(column.options[:proc]).to be_kind_of(Proc)
+ expect(column[:options][:proc]).to be_present
+ expect(column[:options][:proc]).to be_kind_of(Proc)
end
context "custom" do
- let(:custom_column) do
- Class.new(TableCloth::Column) do
- def value(object, view)
- "AN EMAIL!"
- end
- end
- end
+ let(:custom_column) { stub(:custom, value: "AN EMAIL") }
it '.column can take a custom column' do
subject.column :email, using: custom_column
- subject.columns[:email].value(dummy_model, view_context).should == "AN EMAIL!"
+ expect(subject.columns[:email][:class]).to eq(custom_column)
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.