Class: Kentaa::Api::Resources::Base
- Inherits:
-
Object
- Object
- Kentaa::Api::Resources::Base
- Defined in:
- lib/kentaa/api/resources/base.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#endpoint_path ⇒ Object
readonly
Returns the value of attribute endpoint_path.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#resource_class ⇒ Object
readonly
Returns the value of attribute resource_class.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config, options = {}) ⇒ Base
constructor
A new instance of Base.
- #load ⇒ Object
- #loaded? ⇒ Boolean
Constructor Details
#initialize(config, options = {}) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 |
# File 'lib/kentaa/api/resources/base.rb', line 9 def initialize(config, = {}) @config = config @options = @resource_class = .delete(:resource_class) || self.class @endpoint_path = .delete(:endpoint_path) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/kentaa/api/resources/base.rb', line 7 def config @config end |
#endpoint_path ⇒ Object (readonly)
Returns the value of attribute endpoint_path.
7 8 9 |
# File 'lib/kentaa/api/resources/base.rb', line 7 def endpoint_path @endpoint_path end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/kentaa/api/resources/base.rb', line 7 def @options end |
#resource_class ⇒ Object (readonly)
Returns the value of attribute resource_class.
7 8 9 |
# File 'lib/kentaa/api/resources/base.rb', line 7 def resource_class @resource_class end |
Class Method Details
.attribute_key ⇒ Object
17 18 19 20 |
# File 'lib/kentaa/api/resources/base.rb', line 17 def attribute_key class_name = name.split('::').last class_name.gsub(/([^\^])([A-Z])/, '\1_\2').downcase end |
Instance Method Details
#load ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/kentaa/api/resources/base.rb', line 23 def load @response ||= if block_given? yield else load_resource end self end |
#loaded? ⇒ Boolean
34 35 36 |
# File 'lib/kentaa/api/resources/base.rb', line 34 def loaded? !@response.nil? end |