Class: PlanningCenter::Plan

Inherits:
Base
  • Object
show all
Includes:
LazyAttributes
Defined in:
lib/planning_center/plan.rb

Instance Attribute Summary

Attributes included from LazyAttributes

#load_state

Attributes inherited from Base

#attrs

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LazyAttributes

included

Methods inherited from Base

#initialize, #method_missing, #respond_to_missing?

Constructor Details

This class inherits a constructor from PlanningCenter::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PlanningCenter::Base

Class Method Details

.find(id, client) ⇒ Object



31
32
33
34
35
36
# File 'lib/planning_center/plan.rb', line 31

def self.find(id, client)
  attrs = client.get("/plans/#{id}.json")
  plan = new(attrs, client)
  plan.load_state = :loaded
  plan
end

.find_all_for_service_type(service_type_id, client) ⇒ Object



26
27
28
29
# File 'lib/planning_center/plan.rb', line 26

def self.find_all_for_service_type(service_type_id, client)
  plans = client.get("/service_types/#{service_type_id}/plans.json")
  plans.map { |plan| new(plan, client) }
end

Instance Method Details

#itemsObject



38
39
40
# File 'lib/planning_center/plan.rb', line 38

def items
  attrs['items'].map { |item_attrs| Item.new(item_attrs, client) }
end