Class: Card::Env::Success
- Defined in:
- card/lib/card/env/success.rb,
card/lib/card/env/success/target.rb
Overview
Success objects
Defined Under Namespace
Modules: Target
Instance Attribute Summary collapse
-
#card ⇒ Object
writeonly
Sets the attribute card.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#name_context ⇒ Object
Returns the value of attribute name_context.
-
#params ⇒ Object
-
#redirect ⇒ Object
-
#reload ⇒ Object
Returns the value of attribute reload.
Instance Method Summary collapse
-
#<<(value) ⇒ Object
-
#[](key) ⇒ Object
-
#[]=(key, value) ⇒ Object
-
#flash(message = nil) ⇒ Object
-
#in_context(name_context) ⇒ Object
-
#initialize(name_context = nil, success_args = nil) ⇒ Success
constructor
A new instance of Success.
-
#reload? ⇒ Boolean
-
#session ⇒ Object
-
#to_url(name_context = @name_context) ⇒ Object
Methods included from Target
#card, #content=, #id=, #mark=, #target, #target=, #type=, #type_id=
Methods included from Location
#card_path, #card_url, #cardname_from_url, #relative_url_root
Constructor Details
#initialize(name_context = nil, success_args = nil) ⇒ Success
Returns a new instance of Success.
12 13 14 15 16 17 |
# File 'card/lib/card/env/success.rb', line 12 def initialize name_context=nil, success_args=nil @name_context = name_context @new_args = {} @params = OpenStruct.new self << normalize_success_args(success_args) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
81 82 83 84 85 |
# File 'card/lib/card/env/success.rb', line 81 def method_missing method, *args return super unless (m = method.match(/^(\w+(=)?)/)) infer_bracket m[1].to_sym, m[2], args[0] end |
Instance Attribute Details
#card=(value) ⇒ Object (writeonly)
Sets the attribute card
9 10 11 |
# File 'card/lib/card/env/success.rb', line 9 def card=(value) @card = value end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'card/lib/card/env/success.rb', line 10 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'card/lib/card/env/success.rb', line 8 def name @name end |
#name_context ⇒ Object
Returns the value of attribute name_context.
8 9 10 |
# File 'card/lib/card/env/success.rb', line 8 def name_context @name_context end |
#params ⇒ Object
67 68 69 |
# File 'card/lib/card/env/success.rb', line 67 def params @params.marshal_dump end |
#redirect ⇒ Object
37 38 39 |
# File 'card/lib/card/env/success.rb', line 37 def redirect @redirect.present? ? @redirect : false end |
#reload ⇒ Object
Returns the value of attribute reload.
8 9 10 |
# File 'card/lib/card/env/success.rb', line 8 def reload @reload end |
Instance Method Details
#<<(value) ⇒ Object
29 30 31 32 33 34 35 |
# File 'card/lib/card/env/success.rb', line 29 def << value if value.is_a? Hash apply value else self.mark = value end end |
#[](key) ⇒ Object
53 54 55 56 57 58 59 |
# File 'card/lib/card/env/success.rb', line 53 def [] key if respond_to? key.to_sym send key.to_sym else @params.send key.to_sym end end |
#[]=(key, value) ⇒ Object
45 46 47 48 49 50 51 |
# File 'card/lib/card/env/success.rb', line 45 def []= key, value if respond_to? "#{key}=" send "#{key}=", value else @params.send "#{key}=", value end end |
#flash(message = nil) ⇒ Object
61 62 63 64 65 |
# File 'card/lib/card/env/success.rb', line 61 def flash =nil @params[:flash] ||= [] @params[:flash] << if @params[:flash] end |
#in_context(name_context) ⇒ Object
24 25 26 27 |
# File 'card/lib/card/env/success.rb', line 24 def in_context name_context self.name_context = name_context self end |
#reload? ⇒ Boolean
41 42 43 |
# File 'card/lib/card/env/success.rb', line 41 def reload? @reload.to_s == "true" end |