Class: Vericred::Relationships::Base
- Inherits:
-
Object
- Object
- Vericred::Relationships::Base
- Defined in:
- lib/vericred/api_resource/relationships/base.rb
Instance Method Summary collapse
-
#initialize(owner_klass, type) ⇒ Base
constructor
A new instance of Base.
- #owned_klass ⇒ Object
- #plural? ⇒ Boolean
- #root_name ⇒ Object
- #singular? ⇒ Boolean
Constructor Details
#initialize(owner_klass, type) ⇒ Base
Returns a new instance of Base.
4 5 6 7 |
# File 'lib/vericred/api_resource/relationships/base.rb', line 4 def initialize(owner_klass, type) @owner_klass = owner_klass @type = type end |
Instance Method Details
#owned_klass ⇒ Object
9 10 11 |
# File 'lib/vericred/api_resource/relationships/base.rb', line 9 def owned_klass @owned_klass ||= Vericred.const_get(type.to_s.classify) end |
#plural? ⇒ Boolean
13 14 15 |
# File 'lib/vericred/api_resource/relationships/base.rb', line 13 def plural? !singular? end |
#root_name ⇒ Object
21 22 23 |
# File 'lib/vericred/api_resource/relationships/base.rb', line 21 def root_name owned_klass.root_name.pluralize end |
#singular? ⇒ Boolean
17 18 19 |
# File 'lib/vericred/api_resource/relationships/base.rb', line 17 def singular? fail NotImplementedError, 'must implement #singular?' end |