Class: UrlShortener::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/url_shortener/response.rb

Direct Known Subclasses

Expand, Info, Shorten, Stats

Defined Under Namespace

Classes: Expand, Info, Shorten, Stats

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ Response

Returns a new instance of Response.



6
7
8
9
# File 'lib/url_shortener/response.rb', line 6

def initialize(result)
  @result = result
  @attributes = Hashie::Mash.new(result)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



11
12
13
14
# File 'lib/url_shortener/response.rb', line 11

def method_missing(method_name, *args)
  element = camelize(method_name)
  base_element.send(element.to_sym)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/url_shortener/response.rb', line 4

def attributes
  @attributes
end

#resultObject (readonly)

Returns the value of attribute result.



4
5
6
# File 'lib/url_shortener/response.rb', line 4

def result
  @result
end