Module: Alexa::Container

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object

Raises:

  • (Exception)


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/alexa/container.rb', line 14

def method_missing(name)
  myname = ActiveSupport::Inflector.underscore(name).to_sym
  raise Exception.new("there is no data field called \"#{name}\" here!") unless @data.has_key?(myname) || @data.has_key?(myname.to_s)

  if @data.has_key?(myname)
    return @data[myname]
  end

  if @data.has_key?(myname.to_s)
    return @data[myname.to_s]
  end

end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/alexa/container.rb', line 4

def data
  @data
end

Class Method Details

.included(base) ⇒ Object



49
50
51
# File 'lib/alexa/container.rb', line 49

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#keysObject



6
7
8
# File 'lib/alexa/container.rb', line 6

def keys
  @data.keys
end

#to_mongoObject



10
11
12
# File 'lib/alexa/container.rb', line 10

def to_mongo
  self.class.to_mongo(self)
end