Class: Vero::Context
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
- #configure(hash = {}, &block) ⇒ Object
- #configured? ⇒ Boolean
- #disable_requests! ⇒ Object
-
#initialize(object = {}) ⇒ Context
constructor
A new instance of Context.
- #reset! ⇒ Object
Methods included from APIContext
#identify!, #reidentify!, #track!, #unsubscribe!, #update_user!, #update_user_tags!
Constructor Details
#initialize(object = {}) ⇒ Context
Returns a new instance of Context.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vero/context.rb', line 6 def initialize(object = {}) case object when Hash #stub when Vero::Context @config = object.config @subject = object.subject else object = Vero::Config.available_attributes.inject({}) do |hash, symbol| hash[symbol] = object.respond_to?(symbol) ? object.send(symbol) : nil hash end end if object.is_a?(Hash) @config = Vero::Config.new self.configure(object) end end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/vero/context.rb', line 4 def config @config end |
#subject ⇒ Object
Returns the value of attribute subject.
4 5 6 |
# File 'lib/vero/context.rb', line 4 def subject @subject end |
Instance Method Details
#configure(hash = {}, &block) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/vero/context.rb', line 26 def configure(hash = {}, &block) if hash.is_a?(Hash) && hash.any? @config.update_attributes(hash) end block.call(@config) if block_given? end |
#configured? ⇒ Boolean
42 43 44 |
# File 'lib/vero/context.rb', line 42 def configured? @config.configured? end |
#disable_requests! ⇒ Object
38 39 40 |
# File 'lib/vero/context.rb', line 38 def disable_requests! @config.disable_requests! end |
#reset! ⇒ Object
34 35 36 |
# File 'lib/vero/context.rb', line 34 def reset! @config.reset! end |