Class: Metadata::BuilderBase

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
app/models/metadata/builder_base.rb

Direct Known Subclasses

FormBuilder, ViewBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ BuilderBase

Returns a new instance of BuilderBase


4
5
6
7
# File 'app/models/metadata/builder_base.rb', line 4

def initialize(*args, &block)
  super
  @views, @locals, @root, @filter = {}, {}, nil, ->(_) { true }
end

Instance Attribute Details

#locals=(value) ⇒ Object (writeonly)

Sets the attribute locals

Parameters:

  • value

    the value to set the attribute locals to.


2
3
4
# File 'app/models/metadata/builder_base.rb', line 2

def locals=(value)
  @locals = value
end

Instance Method Details

#filter(&block) ⇒ Object


18
19
20
# File 'app/models/metadata/builder_base.rb', line 18

def filter(&block)
  @filter = block
end

#view_for(type, partial_name = nil, &block) ⇒ Object


9
10
11
12
13
14
15
16
# File 'app/models/metadata/builder_base.rb', line 9

def view_for(type, partial_name = nil, &block)
  @views[type.to_sym] =
    if partial_name.nil?
      { inline: capture(&block) }
    else
      { partial: partial_name }
    end
end