Module: Amiando::Attributes

Included in:
Resource, Sync::Event
Defined in:
lib/amiando/attributes.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/amiando/attributes.rb', line 80

def method_missing(method_name, *args, &block)
  if attributes.key?(method_name) && args.empty?
    attributes[method_name]
  else
    super
  end
end

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
# File 'lib/amiando/attributes.rb', line 3

def self.included(base)
  base.class_eval do
    attr_reader :attributes
    extend ClassMethods
  end
end

Instance Method Details

#[](key) ⇒ Object



72
73
74
# File 'lib/amiando/attributes.rb', line 72

def [](key)
  @attributes[key.to_sym]
end

#idObject



64
65
66
# File 'lib/amiando/attributes.rb', line 64

def id
  attributes[:id]
end

#respond_to?(method_name, include_private = false) ⇒ Boolean

Returns:



76
77
78
# File 'lib/amiando/attributes.rb', line 76

def respond_to?(method_name, include_private = false)
  super || attributes.key?(method_name)
end

#typeObject



68
69
70
# File 'lib/amiando/attributes.rb', line 68

def type
  attributes[:type]
end