Module: Interface
- Included in:
- MyInterface, MySubInterface
- Defined in:
- lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/lib/interface.rb
Defined Under Namespace
Classes: MethodMissing
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #append_features(mod) ⇒ Object
- #extend_object(o) ⇒ Object
- #extends(o) ⇒ Object
- #required_methods(*ids) ⇒ Object
- #unrequired_methods(*ids) ⇒ Object
Instance Method Details
#append_features(mod) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/lib/interface.rb', line 15 def append_features(mod) return super if Interface === mod inherited = (self.ancestors-[self]).select{|x| Interface === x}. map{|x| x.instance_variable_get("@ids")} ids = @ids + inherited.flatten @unreq ||= [] (ids-@unreq).uniq.each do |id| unless mod.instance_methods( true ).include?( id.to_s ) raise Interface::MethodMissing, id.to_s end end super mod end |
#extend_object(o) ⇒ Object
9 10 11 12 13 |
# File 'lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/lib/interface.rb', line 9 def extend_object(o) return append_features(o) if Interface === o append_features(class << o; self end) included(o) end |
#extends(o) ⇒ Object
5 6 7 |
# File 'lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/lib/interface.rb', line 5 def extends(o) extend o end |
#required_methods(*ids) ⇒ Object
29 30 31 |
# File 'lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/lib/interface.rb', line 29 def required_methods(*ids) @ids = ids end |
#unrequired_methods(*ids) ⇒ Object
33 34 35 36 |
# File 'lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/lib/interface.rb', line 33 def unrequired_methods(*ids) @unreq ||= [] @unreq += ids end |