Class: Workarea::Content::BlockTypeDefinition

Inherits:
Object
  • Object
show all
Defined in:
app/models/workarea/content/block_type_definition.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define(&block) ⇒ Object



4
5
6
# File 'app/models/workarea/content/block_type_definition.rb', line 4

def self.define(&block)
  new.instance_eval(&block)
end

Instance Method Details

#block_type(name, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'app/models/workarea/content/block_type_definition.rb', line 8

def block_type(name, &block)
  block_type = BlockType.new(name)

  if existing = BlockType.find(block_type.slug)
    existing.instance_eval(&block) if block_given?
  else
    block_type.instance_eval(&block) if block_given?
    Workarea.config.content_block_types.push(block_type)
  end
end