AWS/S3 and subclassing

Discussion in 'Ruby' started by Adam Groves, Apr 7, 2008.

  1. Adam Groves

    Adam Groves Guest

    Hi all,

    How can I make this class return instances of Page instead of instances
    of AWS::S3::S3Object when I call Page.find("mydomain", "mypath")?

    require "rubygems"
    require "aws/s3"

    class Page < AWS::S3::S3Object

    class << self

    alias_method :s3find, :find

    def find(domain, path)
    connect_to_s3
    s3find("#{domain}/#{path}", BUCKET)
    end

    end
    end

    I want to be able to define instance methods for updating or deleting a
    page.

    Grateful for any pointers/suggestions.

    Regards

    Adam
     
    Adam Groves, Apr 7, 2008
    #1
    1. Advertisements

  2. Adam Groves

    Adam Groves Guest

    OK. I've realised why this is happening. S3Object.find delegates to
    Bucket.find and Bucket.find returns an array of S3Object instances.
     
    Adam Groves, Apr 7, 2008
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.