Class: Resourcerer::Resource
- Inherits:
-
Object
- Object
- Resourcerer::Resource
- Defined in:
- lib/resourcerer/resource.rb
Instance Attribute Summary collapse
-
#config_proc ⇒ Object
readonly
Returns the value of attribute config_proc.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Class Method Summary collapse
Instance Method Summary collapse
- #call(controller) ⇒ Object
-
#initialize(strategy, name, options, config_proc = nil) ⇒ Resource
constructor
A new instance of Resource.
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, , config_proc=nil) @strategy, @name, @options, @config_proc = strategy, name, , config_proc end |
Instance Attribute Details
#config_proc ⇒ Object (readonly)
Returns the value of attribute config_proc.
6 7 8 |
# File 'lib/resourcerer/resource.rb', line 6 def config_proc @config_proc end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/resourcerer/resource.rb', line 6 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/resourcerer/resource.rb', line 6 def @options end |
#strategy ⇒ Object (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, ={}, config_proc=nil) strategy_class = .delete(:strategy) || Strategies::StrongParametersStrategy new strategy_class, name, , 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, , config_proc).resource end |