Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make options for configurable elements instantiate from an array.

  • Loading branch information...
commit 1030486a889880108e6edaa8be2108e86e376182 1 parent 716662c
@bobbytables authored
Showing with 6 additions and 13 deletions.
  1. +6 −13 lib/table_cloth/configurable_elements.rb
View
19 lib/table_cloth/configurable_elements.rb
@@ -1,21 +1,14 @@
module TableCloth
module ConfigurableElements
+ OPTIONS = %w(table thead th tbody tr td).map(&:to_sym)
+
extend ActiveSupport::Concern
included do
- cattr_accessor :table
- cattr_accessor :thead
- cattr_accessor :th
- cattr_accessor :tbody
- cattr_accessor :tr
- cattr_accessor :td
-
- self.table = ActiveSupport::OrderedOptions.new
- self.thead = ActiveSupport::OrderedOptions.new
- self.th = ActiveSupport::OrderedOptions.new
- self.tbody = ActiveSupport::OrderedOptions.new
- self.tr = ActiveSupport::OrderedOptions.new
- self.td = ActiveSupport::OrderedOptions.new
+ OPTIONS.each do |option|
+ cattr_accessor option
+ self.send "#{option}=", ActiveSupport::OrderedOptions.new
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.