Class: Object::Extendable
- Defined in:
- lib/railings/extensions/extendable.rb
Instance Method Summary collapse
- #class ⇒ Object
-
#initialize(object, parts = []) ⇒ Extendable
constructor
A new instance of Extendable.
- #to_hash ⇒ Object
Methods inherited from String
#parenthesize, #questionable, #questionable!, #questionable?
Constructor Details
#initialize(object, parts = []) ⇒ Extendable
Returns a new instance of Extendable.
3 4 5 6 |
# File 'lib/railings/extensions/extendable.rb', line 3 def initialize object, parts = [] @object, @parts = [object, parts.clone] replace parts.insert(0, object.class.name.demodulize.downcase.dasherize).join('-') end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object (private)
20 21 22 |
# File 'lib/railings/extensions/extendable.rb', line 20 def method_missing symbol, *args Extendable.new @object, @parts.push(symbol.to_s) end |
Instance Method Details
#class ⇒ Object
8 9 10 |
# File 'lib/railings/extensions/extendable.rb', line 8 def class Extendable.new @object, @parts[1..-1].to_a end |
#to_hash ⇒ Object
12 13 14 15 16 17 |
# File 'lib/railings/extensions/extendable.rb', line 12 def to_hash { :class => self.class, :id => self } end |