Module: Resourcerer::Controller::ClassMethods

Defined in:
lib/resourcerer/controller.rb

Instance Method Summary collapse

Instance Method Details

#resource(name, **options, &block) ⇒ Object

Public: Defines a Resource in a controller Class.

name - The name of the method to define. **options - See Resource#initialize for details. block - If supplied, the block is executed to provide options.

Returns the name of the defined resource.



31
32
33
# File 'lib/resourcerer/controller.rb', line 31

def resource(name, **options, &block)
  Resource.define(self, name, **options, &block)
end

#resourcerer_config(name, **options, &block) ⇒ Object

Public: Defines a Configuration preset that can be reused in different Resources by providing the :using option.

name - The Symbol name of the configuration preset. options - The Hash of options to define the preset. block - If supplied, the block is executed to provide options.

Returns a Hash with all the resource configurations.



43
44
45
46
47
# File 'lib/resourcerer/controller.rb', line 43

def resourcerer_config(name, **options, &block)
  self.resourcerer_configuration = (resourcerer_configuration || {}).merge(
    name => Configuration.new(options, &block)
  )
end