Module: ShowFor::Attribute

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

Instance Method Summary collapse

Instance Method Details

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



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

#attributes(*attribute_names) ⇒ Object



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

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



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