Sha256: 6da98d0e14e070c2b8c0cd5bfa2849351d646b098b5c0452d9bdcc971c8f1af0
Contents?: true
Size: 761 Bytes
Versions: 4
Compression:
Stored size: 761 Bytes
Contents
module Wayback class Factory # Instantiates a new action object # # @param attrs [Hash] # @raise [ArgumentError] Error raised when supplied argument is missing an :action key. # @return [Wayback::Action::Favorite, Wayback::Action::Follow, Wayback::Action::ListMemberAdded, Wayback::Action::Mention, Wayback::Action::Reply, Wayback::Action::Retweet] def self.fetch_or_new(method, klass, attrs={}) return unless attrs type = attrs.delete(method.to_sym) if type const_name = type.gsub(/\/(.?)/){"::#{$1.upcase}"}.gsub(/(?:^|_)(.)/){$1.upcase} klass.const_get(const_name.to_sym).fetch_or_new(attrs) else raise ArgumentError, "argument must have :#{method} key" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
wayback-0.3.1 | lib/wayback/factory.rb |
wayback-0.2.1 | lib/wayback/factory.rb |
wayback-0.2.0 | lib/wayback/factory.rb |
wayback-0.1.0 | lib/wayback/factory.rb |