Class: XRBP::Model::Base
- Inherits:
-
Object
- Object
- XRBP::Model::Base
- Defined in:
- lib/xrbp/model/base.rb
Overview
Base model definition, provides common logic to set connection & opts.
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#opts ⇒ Object
Returns the value of attribute opts.
Instance Method Summary collapse
- #full_opts ⇒ Object
-
#initialize(opts = {}) ⇒ Base
constructor
A new instance of Base.
- #set_opts(opts = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Base
Returns a new instance of Base.
17 18 19 |
# File 'lib/xrbp/model/base.rb', line 17 def initialize(opts={}) set_opts(opts) end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
15 16 17 |
# File 'lib/xrbp/model/base.rb', line 15 def connection @connection end |
#opts ⇒ Object
Returns the value of attribute opts.
15 16 17 |
# File 'lib/xrbp/model/base.rb', line 15 def opts @opts end |
Instance Method Details
#full_opts ⇒ Object
27 28 29 |
# File 'lib/xrbp/model/base.rb', line 27 def full_opts (self.class.opts || {}).merge(opts || {}).except(:connection) end |
#set_opts(opts = {}) ⇒ Object
21 22 23 24 25 |
# File 'lib/xrbp/model/base.rb', line 21 def set_opts(opts={}) @opts ||= {} @opts.merge!(opts) @connection = opts[:connection] if opts[:connection] end |