Module: ShowFor::Attribute

Included in:
Builder
Defined in:
lib/show_for/attribute.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) attribute(attribute_name, options = {}, &block)



3
4
5
6
7
8
9
10
11
# File 'lib/show_for/attribute.rb', line 3

def attribute(attribute_name, options={}, &block)
  apply_default_options!(attribute_name, options)
  block = block_from_value_option(attribute_name, options) unless block
  collection_block, block = block, nil if collection_block?(block)

  value = attribute_value(attribute_name, &block)

  wrap_label_and_content(attribute_name, value, options, &collection_block)
end

- (Object) attributes(*attribute_names)



22
23
24
25
26
# File 'lib/show_for/attribute.rb', line 22

def attributes(*attribute_names)
  attribute_names.map do |attribute_name|
    attribute(attribute_name)
  end.join.html_safe
end

- (Object) value(attribute_name, options = {}, &block)



13
14
15
16
17
18
19
20
# File 'lib/show_for/attribute.rb', line 13

def value(attribute_name, options={}, &block)
  apply_default_options!(attribute_name, options)
  collection_block, block = block, nil if collection_block?(block)

  value = attribute_value(attribute_name, &block)

  wrap_content(attribute_name, value, options, &collection_block)
end