Class: Videojuicer::Campaign::CampaignPolicy
Instance Attribute Summary collapse
#local_config
Instance Method Summary
collapse
Methods included from Resource
#destroy, #errors, #errors=, #errors_on, included, #new_record?, #reload, #save, #update_attributes, #valid?, #validate_response
included
#attr_get, #attr_set, #attributes, #attributes=, #coerce_value, #default_attributes, included, inherited, #initialize, #returnable_attributes
included
#proxy_for
#api_version, #config, #configure!, #consumer_key, #consumer_secret, #host, #port, #protocol, #scope, #seed_name, #token, #token_secret, #user_id
Instance Attribute Details
Returns the value of attribute criteria.
16
17
18
|
# File 'lib/videojuicer/campaign_policy.rb', line 16
def criteria
@criteria
end
|
Instance Method Details
#add_criteria(*criteria) ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/videojuicer/campaign_policy.rb', line 57
def add_criteria(*criteria)
responses = criteria.map do |criterion|
proxy_for(config).post("#{path_for_dependents}#{criterion.class.base_path}", {:criterion => criterion.attributes})
end
self.reload
responses
end
|
95
96
97
98
99
100
101
|
# File 'lib/videojuicer/campaign_policy.rb', line 95
def add_promo(*promos)
responses = promos.map do |promo|
proxy_for(config).post("#{path_for_dependents}#{promo.class.base_path}", {:promo => promo.attributes})
end
self.reload
responses
end
|
#path_for_dependents ⇒ Object
111
112
113
|
# File 'lib/videojuicer/campaign_policy.rb', line 111
def path_for_dependents
self.class.compile_route(self.class.nesting_route,{:campaign_policy_id => self.id, :campaign_id => self.campaign_id})
end
|
83
84
85
|
# File 'lib/videojuicer/campaign_policy.rb', line 83
def promos
@promos.values.flatten
end
|
73
74
75
76
77
78
79
80
81
|
# File 'lib/videojuicer/campaign_policy.rb', line 73
def promos=(object_hash={})
@promos = {}
object_hash.map do |type_sym, promos|
@promos[type_sym.to_sym] =
promos.map do |promo|
Videojuicer::Promo.model_map[type_sym.to_sym].new(promo)
end
end
end
|
#remove_criteria(*criteria) ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/videojuicer/campaign_policy.rb', line 65
def remove_criteria(*criteria)
responses = criteria.map do |criterion|
proxy_for(config).delete("#{path_for_dependents}#{criterion.class.base_path}", {:criterion => criterion.attributes})
end
self.reload
responses
end
|
103
104
105
106
107
108
109
|
# File 'lib/videojuicer/campaign_policy.rb', line 103
def remove_promo(*promos)
responses = promos.map do |promo|
proxy_for(config).delete("#{path_for_dependents}#{promo.class.base_path}", {:promo => promo.attributes})
end
self.reload
responses
end
|