Sha256: 0da2cdaf7f93cc2517be802c47b7f64c2b5729d92f69c7687641caa26479642e
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
module Zertico class Accessor def initialize(object) instance_variable_set("@#{interface_name}", object) end def self.find(id) new(interface_class.find(id)) end def interface instance_variable_get("@#{interface_name}") end def method_missing(method_name, *args) if interface.respond_to?(method_name) return interface.send(method_name, *args) end super end def respond_to_missing?(method_name, include_private = false) return true if interface.respond_to?(method_name) super end protected def self.interface_name self.interface_class.name.split('::').last.singularize.underscore end def self.interface_class begin self.name.chomp('Accessor').constantize rescue NameError self.name.chomp('Accessor').split('::').last.constantize end end def interface_name self.class.interface_name end def interface_class self.class.interface_class end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
zertico-1.1.1 | lib/zertico/accessor.rb |
zertico-1.1.0 | lib/zertico/accessor.rb |
zertico-1.0.0 | lib/zertico/accessor.rb |