Class: Transmission::Model::Session
- Inherits:
-
Object
- Object
- Transmission::Model::Session
- Defined in:
- lib/transmission/model/session.rb
Defined Under Namespace
Classes: SessionError
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#connector ⇒ Object
Returns the value of attribute connector.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(session_object, connector) ⇒ Session
constructor
A new instance of Session.
- #method_missing(symbol, *args) ⇒ Object
- #save! ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(session_object, connector) ⇒ Session
Returns a new instance of Session.
8 9 10 11 |
# File 'lib/transmission/model/session.rb', line 8 def initialize(session_object, connector) @attributes = session_object @connector = connector end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/transmission/model/session.rb', line 22 def method_missing(symbol, *args) string = symbol.to_s if string[-1] == '=' string = string[0..-2] key = Transmission::Arguments::SessionSet.real_key string return @attributes[key] = args.first if !!key else key = Transmission::Fields::SessionGet.real_key string return @attributes[key] if !!key end super end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/transmission/model/session.rb', line 6 def attributes @attributes end |
#connector ⇒ Object
Returns the value of attribute connector.
6 7 8 |
# File 'lib/transmission/model/session.rb', line 6 def connector @connector end |
Class Method Details
.connector ⇒ Object
42 43 44 |
# File 'lib/transmission/model/session.rb', line 42 def connector Transmission::Config.get_connector end |
Instance Method Details
#save! ⇒ Object
13 14 15 16 |
# File 'lib/transmission/model/session.rb', line 13 def save! filtered = Transmission::Arguments::SessionSet.filter @attributes connector.set_session filtered end |
#to_json ⇒ Object
18 19 20 |
# File 'lib/transmission/model/session.rb', line 18 def to_json @attributes end |