Sha256: 53d6ecae0933833cdbd826597c7f45ec28b6aea5270e2a4501e85b8c4e241a0f

Contents?: true

Size: 521 Bytes

Versions: 5

Compression:

Stored size: 521 Bytes

Contents

# a small hack - Things references a collection of Todos as to_dos
# here we make an alias so todos is also possible
module Appscript #:nodoc:
  class Reference #:nodoc:
    def todos
      to_dos
    end
    
    def identify
      name = self.to_s.match(/Things.app"\)\.([^\.]*)/)[1]
    
      begin
        name = name.gsub('_', '')
        # inflections
        name = 'persons' if name == 'people'
        Things.const_get(name.capitalize[0..-2]) 
      rescue NameError
        nil
      end
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
things-client-0.2.4 lib/appscript/reference.rb
things-client-0.2.3 lib/appscript/reference.rb
things-client-0.2.2 lib/appscript/reference.rb
things-client-0.2.1 lib/appscript/reference.rb
things-client-0.2.0 lib/appscript/reference.rb