Module: ActsAsCitable::InstanceMethods
- Defined in:
- lib/acts_as_citable/base.rb
Instance Method Summary collapse
-
#method_missing(meth, *args, &block) ⇒ Object
The method_missing override checks to see if the called method can be evaluated to a method name and parameter, then stores it and calls it if it can.
-
#respond_to?(meth, include_private = false) ⇒ Boolean
Returns true if the method can be evaluated to a method name and parameter.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
The method_missing override checks to see if the called method can be evaluated to a method name and parameter, then stores it and calls it if it can. For example, to_csf or from_pnx. pnx_to will not work.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/acts_as_citable/base.rb', line 31 def method_missing(meth, *args, &block) # Check to see if it can be evaluated if(matches? meth) #Defines the method and caches it to the class self.class.send(:define_method, meth) do # Uses data_field and format_field to translate the metadata. # debugger Citero.map(_data).send("from_#{_format}").send(meth) end # calls the method send meth, *args, &block else super end end |
Instance Method Details
#respond_to?(meth, include_private = false) ⇒ Boolean
Returns true if the method can be evaluated to a method name and parameter.
49 50 51 52 53 54 55 |
# File 'lib/acts_as_citable/base.rb', line 49 def respond_to? meth, include_private=false if(matches? meth) return true else super end end |