module Piwik::DataMethods
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
Public Class Methods
included(base)
click to toggle source
# File lib/piwik/data_methods.rb, line 23 def self.included(base) include Piwik::Typecast base.send(:include, InstanceMethods) attr_accessor :data,:value end