Method: OpenGraphReader::Object::DSL#content

Defined in:
lib/open_graph_reader/object/dsl.rb

#content(type, *args, options = {}) ⇒ Object

Set the type for the content attribute

Parameters:

  • type (Symbol)

    one of the registered types.

  • args (Array<Object>)

    Additional parameters for the type

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :downcase (Bool) — default: false

    Normalize the contents case to lowercase.



129
130
131
132
133
134
135
136
137
138
# File 'lib/open_graph_reader/object/dsl.rb', line 129

def content type, *args
  options = args.pop if args.last.is_a? Hash
  options ||= {}

  @content_processor = proc {|value|
    value.downcase! if options[:downcase]
    options[:to] ||= self
    DSL.processors[type].call(value, *args, options)
  }
end