Class: ActiveRequest::Base
- Inherits:
-
Object
- Object
- ActiveRequest::Base
- Includes:
- Attributes, Errors, HasMany, Queries, HTTParty
- Defined in:
- lib/active_request/base.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ Base
constructor
A new instance of Base.
Methods included from Queries
Methods included from Attributes
Methods included from HasMany
Methods included from Errors
Constructor Details
#initialize(options = nil) ⇒ Base
Returns a new instance of Base.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/active_request/base.rb', line 11 def initialize( = nil) if .present? .symbolize_keys! attributes.each do |att| send("#{att}=", [att]) if [att].present? end belongs_tos.each do |att| simble = att[:foreign_key].to_sym send("#{att[:foreign_key]}=", [simble]) if [simble].present? end if belongs_tos end self.class.base_uri("#{ActiveRequest.configuration.uri}/#{ActiveRequest.configuration.api_version}/") end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/active_request/base.rb', line 9 def errors @errors end |
Class Method Details
.model_name ⇒ Object
25 26 27 |
# File 'lib/active_request/base.rb', line 25 def self.model_name name.underscore.pluralize end |
.new(*args, &blk) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/active_request/base.rb', line 29 def self.new(*args, &blk) alloc = allocate build_has_manys(alloc) build_belongs_tos(alloc) alloc.instance_eval { initialize(*args, &blk) } alloc end |