Module: ActsAsRunnableCode::ClassMethods
- Defined in:
- lib/acts_as_runnable_code.rb
Instance Attribute Summary collapse
-
#runnable_code_options ⇒ Object
Returns the value of attribute runnable_code_options.
Instance Method Summary collapse
-
#runnable_classes ⇒ Object
a list of runnable classes in the format [“SomeClassWrapper”, “OtherClassWraper”].
- #runnable_code? ⇒ Boolean
-
#runnable_methods ⇒ Object
a list of runnable methods in the format {“SomeClassWrapper” => [“method_a”, “method_b”], “OtherClassWraper” => [“method_c”, “method_d”]].
-
#runnable_methods_no_object ⇒ Object
same as runnable methods but excludes all the methods of +Object.
- #source_code_field ⇒ Object
Instance Attribute Details
#runnable_code_options ⇒ Object
Returns the value of attribute runnable_code_options.
48 49 50 |
# File 'lib/acts_as_runnable_code.rb', line 48 def @runnable_code_options end |
Instance Method Details
#runnable_classes ⇒ Object
a list of runnable classes in the format [“SomeClassWrapper”, “OtherClassWraper”]
59 60 61 |
# File 'lib/acts_as_runnable_code.rb', line 59 def runnable_classes ([:classes] || ActsAsWrappedClass::WRAPPED_CLASSES).collect { |c| "#{c}Wrapper" } end |
#runnable_code? ⇒ Boolean
54 55 56 |
# File 'lib/acts_as_runnable_code.rb', line 54 def runnable_code? true end |
#runnable_methods ⇒ Object
a list of runnable methods in the format {“SomeClassWrapper” => [“method_a”, “method_b”], “OtherClassWraper” => [“method_c”, “method_d”]]
64 65 66 67 68 69 70 71 72 |
# File 'lib/acts_as_runnable_code.rb', line 64 def runnable_methods meths = {} runnable_classes.each { |c| klass = eval("::#{c}") meths[c.to_s] ||= [] meths[c.to_s] += klass.allowed_methods if klass.respond_to?(:allowed_methods) } meths end |
#runnable_methods_no_object ⇒ Object
same as runnable methods but excludes all the methods of +Object
75 76 77 78 79 80 81 |
# File 'lib/acts_as_runnable_code.rb', line 75 def runnable_methods_no_object newv = {} runnable_methods.each do |k,v| newv[k] = v - Object.public_instance_methods end newv end |
#source_code_field ⇒ Object
50 51 52 |
# File 'lib/acts_as_runnable_code.rb', line 50 def source_code_field (@runnable_code_options[:code_field] || "code").to_sym end |