Class: Refinery::Pages::Types

Inherits:
Array
  • Object
show all
Defined in:
pages/lib/refinery/pages/types.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.register(name) {|type| ... } ⇒ Object

Yields:

  • (type)

14
15
16
17
18
19
20
21
22
23
# File 'pages/lib/refinery/pages/types.rb', line 14

def register(name, &block)
  type = Type.new
  type.name = name

  yield type if block_given?

  raise "A page type must have a name: #{self.inspect}" if type.name.blank?

  registered << type
end

.registeredObject


25
26
27
# File 'pages/lib/refinery/pages/types.rb', line 25

def registered
  @registered_types ||= new
end

Instance Method Details

#find_by_name(name) ⇒ Object


9
10
11
# File 'pages/lib/refinery/pages/types.rb', line 9

def find_by_name(name)
  detect { |type| type.name.to_s.downcase == name.to_s.downcase}
end

#register(name, &block) ⇒ Object


5
6
7
# File 'pages/lib/refinery/pages/types.rb', line 5

def register(name, &block)
  self.class.register(name, &block)
end