Class: XRBP::Model::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/xrbp/model/base.rb

Overview

Base model definition, provides common logic to set connection & opts.

Direct Known Subclasses

Account, Gateway, Ledger, Market, Node, Validator

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#connectionObject

Returns the value of attribute connection


15
16
17
# File 'lib/xrbp/model/base.rb', line 15

def connection
  @connection
end

#optsObject

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_optsObject


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