Module: Piwik::DataMethods

Included in:
ApiModule, ApiResponse
Defined in:
lib/piwik/data_methods.rb

Overview

Provides a more intuitive interface to API responses. Responses may return a value or structured data, and objects will figure out what kind or response they are getting, and stick them in the appropriate instance variable. Value responses are accessed directly: Example:

Piwik::VisitsSummary.getVisits(:idSite => 7, :period => :day, :date => Date.today).value
=> 467

Data Responses can be accessed either as a Hash or an object. Example:

s = Piwik::API.getSettings
=> #<Piwik::API::Settings:[snip] @data={"SDK_batch_size"=>"10", "SDK_interval_value"=>"30"}> 
s.SDK_batch_size
=> 10
s['SDK_batch_size']
=> 10
s.data['SDK_batch_size']
=> 10

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object


23
24
25
26
27
# File 'lib/piwik/data_methods.rb', line 23

def self.included(base)
  include Piwik::Typecast
  base.send(:include, InstanceMethods)
  attr_accessor :data,:value
end