Module: Enumish
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/enumish.rb,
lib/enumish/version.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
"0.9.2"
Instance Method Summary collapse
-
#method_missing(method_id, *args, &block) ⇒ Object
Allow calls such as object.friendly? or model.attitude.friendly?.
- #to_s ⇒ Object
- #to_sym ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args, &block) ⇒ Object
Allow calls such as object.friendly? or model.attitude.friendly?
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/enumish.rb', line 36 def method_missing(method_id, *args, &block) = if method_id.to_s.match(/\?$/) && args.empty? && block.nil? method_id.to_s.sub(/\?$/, "") end if && self.class.enum_ids.include?() self.send(self.class.enum_id.to_s) == else super end end |
Instance Method Details
#to_s ⇒ Object
48 49 50 |
# File 'lib/enumish.rb', line 48 def to_s self.send(self.class.enum_id).to_s end |
#to_sym ⇒ Object
52 53 54 |
# File 'lib/enumish.rb', line 52 def to_sym self.send(self.class.enum_id).to_sym end |