Class: Fabricio::Model::AbstractModel

Inherits:
Object
  • Object
show all
Defined in:
lib/fabricio/models/abstract_model.rb

Overview

Defines a base class for all data models

Direct Known Subclasses

App, Build, Issue, IssueSession, Organization

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object

We use ‘method_missing` approach here to allow a user query any field from the original data structure sent by server.

Raises:

  • (NoMethodError)


9
10
11
12
13
14
# File 'lib/fabricio/models/abstract_model.rb', line 9

def method_missing(*args)
  method_name = args.first
  json_value = @json[method_name.to_s]
  return json_value if json_value
  raise NoMethodError.new("There's no method called #{args.first} here -- please try again.", args.first)
end

Instance Attribute Details

#jsonObject

Plain data from the server



6
7
8
# File 'lib/fabricio/models/abstract_model.rb', line 6

def json
  @json
end