Module: Halogen::Collection

Defined in:
lib/halogen/collection.rb

Overview

Behavior for representers with a primary collection resource.

The main reason to declare a collection is that the resource with that name will always be embedded during rendering.

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/halogen/collection.rb', line 8

def self.included(base) # :nodoc:
  if base.included_modules.include?(Resource)
    fail InvalidCollection, "#{base.name} has already defined a resource"
  end

  base.extend ClassMethods

  base.send :include, InstanceMethods

  base.class.send :attr_accessor, :collection_name
end