Class: MerbResourceScope::Specification
- Inherits:
-
Object
- Object
- MerbResourceScope::Specification
- Defined in:
- lib/merb-resource-scope/specification.rb
Instance Attribute Summary collapse
-
#association_method ⇒ Object
Returns the value of attribute association_method.
-
#find_method ⇒ Object
Returns the value of attribute find_method.
-
#foreign_key ⇒ Object
Returns the value of attribute foreign_key.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#klass_name ⇒ Object
Returns the value of attribute klass_name.
-
#name_prefix ⇒ Object
Returns the value of attribute name_prefix.
-
#permalink ⇒ Object
Returns the value of attribute permalink.
-
#resource_name ⇒ Object
Returns the value of attribute resource_name.
-
#scope_depth ⇒ Object
Returns the value of attribute scope_depth.
-
#singleton ⇒ Object
Returns the value of attribute singleton.
Class Method Summary collapse
-
.create(association_method, options = {}) ⇒ Specification
create a specification instance.
Instance Method Summary collapse
-
#initialize(association_method, options = {}) ⇒ Specification
constructor
A new instance of Specification.
Constructor Details
#initialize(association_method, options = {}) ⇒ Specification
Returns a new instance of Specification.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/merb-resource-scope/specification.rb', line 16 def initialize(association_method, = {}) @association_method = [:association_method] && [:association_method].to_s || association_method.to_s @resource_name = [:resource_name] && [:resource_name].to_s || Extlib::Inflection.singularize(@association_method) @singleton = [:singleton] || false @klass_name = [:class_name] || Extlib::Inflection.classify(@resource_name) @klass = Object.full_const_get(@klass_name) rescue nil @find_method = [:find_method] @scope_depth = [:scope_depth] @permalink = [:permalink] || :id @name_prefix = [:name_prefix] @foreign_key = [:foreign_key] || @permalink == :id ? Extlib::Inflection.foreign_key(@resource_name).to_sym : @permalink end |
Instance Attribute Details
#association_method ⇒ Object
Returns the value of attribute association_method.
14 15 16 |
# File 'lib/merb-resource-scope/specification.rb', line 14 def association_method @association_method end |
#find_method ⇒ Object
Returns the value of attribute find_method.
14 15 16 |
# File 'lib/merb-resource-scope/specification.rb', line 14 def find_method @find_method end |
#foreign_key ⇒ Object
Returns the value of attribute foreign_key.
14 15 16 |
# File 'lib/merb-resource-scope/specification.rb', line 14 def foreign_key @foreign_key end |
#klass ⇒ Object
Returns the value of attribute klass.
14 15 16 |
# File 'lib/merb-resource-scope/specification.rb', line 14 def klass @klass end |
#klass_name ⇒ Object
Returns the value of attribute klass_name.
14 15 16 |
# File 'lib/merb-resource-scope/specification.rb', line 14 def klass_name @klass_name end |
#name_prefix ⇒ Object
Returns the value of attribute name_prefix.
14 15 16 |
# File 'lib/merb-resource-scope/specification.rb', line 14 def name_prefix @name_prefix end |
#permalink ⇒ Object
Returns the value of attribute permalink.
14 15 16 |
# File 'lib/merb-resource-scope/specification.rb', line 14 def permalink @permalink end |
#resource_name ⇒ Object
Returns the value of attribute resource_name.
14 15 16 |
# File 'lib/merb-resource-scope/specification.rb', line 14 def resource_name @resource_name end |
#scope_depth ⇒ Object
Returns the value of attribute scope_depth.
14 15 16 |
# File 'lib/merb-resource-scope/specification.rb', line 14 def scope_depth @scope_depth end |
#singleton ⇒ Object
Returns the value of attribute singleton.
14 15 16 |
# File 'lib/merb-resource-scope/specification.rb', line 14 def singleton @singleton end |
Class Method Details
.create(association_method, options = {}) ⇒ Specification
create a specification instance
31 32 33 34 |
# File 'lib/merb-resource-scope/specification.rb', line 31 def self.create(association_method, = {}) = .only(:association_method, :class_name, :singleton, :find_method, :resource_name, :foreign_key, :scope_depth, :permalink, :name_prefix) new(association_method, ) end |