Class: Resourcerer::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/resourcerer/resource.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(strategy, name, options, config_proc = nil) ⇒ Resource

Returns a new instance of Resource.



13
14
15
# File 'lib/resourcerer/resource.rb', line 13

def initialize(strategy, name, options, config_proc=nil)
  @strategy, @name, @options, @config_proc = strategy, name, options, config_proc
end

Instance Attribute Details

#config_procObject (readonly)

Returns the value of attribute config_proc.



6
7
8
# File 'lib/resourcerer/resource.rb', line 6

def config_proc
  @config_proc
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/resourcerer/resource.rb', line 6

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/resourcerer/resource.rb', line 6

def options
  @options
end

#strategyObject (readonly)

Returns the value of attribute strategy.



6
7
8
# File 'lib/resourcerer/resource.rb', line 6

def strategy
  @strategy
end

Class Method Details

.for(name, options = {}, config_proc = nil) ⇒ Object



8
9
10
11
# File 'lib/resourcerer/resource.rb', line 8

def self.for(name, options={}, config_proc=nil)
  strategy_class = options.delete(:strategy) || Strategies::StrongParametersStrategy
  new strategy_class, name, options, config_proc
end

Instance Method Details

#call(controller) ⇒ Object



17
18
19
# File 'lib/resourcerer/resource.rb', line 17

def call(controller)
  strategy.new(controller, name, options, config_proc).resource
end