Module: Resourcelogic::Singleton::Methods
- Defined in:
- lib/resourcelogic/singleton.rb
Instance Method Summary collapse
- #build_object ⇒ Object
- #object ⇒ Object
-
#object_url_parts(action = nil, *alternate_object_or_params) ⇒ Object
Route alises can only be used for singleton, like account => user.
- #scope ⇒ Object
-
#singleton? ⇒ Boolean
Override me with true to make singleton.
Instance Method Details
#build_object ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/resourcelogic/singleton.rb', line 28 def build_object if singleton? && parent? scope.send("build_#{model_name}") else super end end |
#object ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/resourcelogic/singleton.rb', line 12 def object return @object if defined?(@object) if singleton? if !parent? && respond_to?("current_#{model_name}", true) @object = send("current_#{model_name}") elsif parent? && parent.send(model_name) @object = parent.send(model_name) else super end else super end end |
#object_url_parts(action = nil, *alternate_object_or_params) ⇒ Object
Route alises can only be used for singleton, like account => user. Otherwise the urligence wont work because there is no account model.
45 46 47 |
# File 'lib/resourcelogic/singleton.rb', line 45 def object_url_parts(action = nil, *alternate_object_or_params) singleton? ? ([action] + contexts_url_parts + [route_name]) : super end |
#scope ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/resourcelogic/singleton.rb', line 36 def scope if singleton? && parent? parent else super end end |
#singleton? ⇒ Boolean
Override me with true to make singleton
50 51 52 |
# File 'lib/resourcelogic/singleton.rb', line 50 def singleton? false end |