Module: DomFor

Extended by:
ActiveSupport::Autoload
Includes:
Model, Record
Defined in:
lib/dom_for.rb,
lib/dom_for/model.rb,
lib/dom_for/record.rb,
lib/dom_for/version.rb

Defined Under Namespace

Modules: Model, Record

Constant Summary collapse

VERSION =
'1.0.2'

Instance Method Summary collapse

Methods included from Record

#dom_for_record

Methods included from Model

#dom_for_model

Instance Method Details

#dom_for(object, attrs = {}, &block) ⇒ String

Creates a div tag with the attributes for the model or record of ActiveRecord

Parameters:

  • object (ActiveRecord::Base, Class)

    Model or record of ActiveRecord

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

    Additional attributes for the record

  • block (Proc)

    Block for a div tag

Returns:

  • (String)

    Sanitized HTML string



33
34
35
36
37
38
39
# File 'lib/dom_for.rb', line 33

def dom_for(object, attrs={}, &block)
  if object.instance_of? Class
    dom_for_model(object, attrs, &block)
  else
    dom_for_record(object, attrs, &block)
  end
end