Module: Ehon
- Defined in:
- lib/ehon.rb,
lib/ehon/version.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary
collapse
- VERSION =
"0.1.3"
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
26
27
28
29
|
# File 'lib/ehon.rb', line 26
def method_missing(symbol, *args)
return read_attribute(symbol) if respond_to?(symbol)
super
end
|
Class Method Details
.included(base) ⇒ Object
4
5
6
7
8
|
# File 'lib/ehon.rb', line 4
def self.included(base)
base.extend ClassMethods
base.contents = {}
base.default_options = {}
end
|
Instance Method Details
#==(other) ⇒ Object
18
19
20
|
# File 'lib/ehon.rb', line 18
def ==(other)
(self.class == other.class) && (self.id == other.id)
end
|
#initialize(id, options = {}) ⇒ Object
10
11
12
|
# File 'lib/ehon.rb', line 10
def initialize(id, options = {})
@options = options.merge(id: id)
end
|
#options ⇒ Object
14
15
16
|
# File 'lib/ehon.rb', line 14
def options
self.class.default_options.merge(@options)
end
|
#read_attribute(symbol) ⇒ Object
31
32
33
|
# File 'lib/ehon.rb', line 31
def read_attribute(symbol)
self.options[symbol]
end
|
#respond_to_missing?(symbol, include_private = false) ⇒ Boolean
22
23
24
|
# File 'lib/ehon.rb', line 22
def respond_to_missing?(symbol, include_private = false)
self.options.has_key?(symbol)
end
|