Module: TableCloth::Extensions::RowAttributes::ClassMethods

Defined in:
lib/table_cloth/extensions/row_attributes.rb

Instance Method Summary collapse

Instance Method Details

#row_attributes(*args, &block) ⇒ Object



9
10
11
12
13
14
# File 'lib/table_cloth/extensions/row_attributes.rb', line 9

def row_attributes(*args, &block)
  @tr_options ||= {}
  options = args.extract_options! || {}
  options[:proc] = block if block_given?
  @tr_options = options
end

#tr_optionsObject



16
17
18
19
20
21
22
# File 'lib/table_cloth/extensions/row_attributes.rb', line 16

def tr_options
  @tr_options ||= {}
  if superclass.respond_to? :tr_options
    @tr_options = superclass.tr_options.merge(@tr_options)
  end
  @tr_options
end

#tr_options_for(object) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/table_cloth/extensions/row_attributes.rb', line 24

def tr_options_for(object)
  options = tr_options
  if options.include?(:proc)
    result = options[:proc].call(object) || {}
    options.except(:proc).merge(result)
  else
    options
  end
end