Sha256: c9a326291d0f60af9630110734438dd5229032a413f4f1d65c879ce40fd0290f

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

require 'contextio/api/association_helpers'

class ContextIO
  class BodyPart
    def self.association_name
      :body_part
    end
    ContextIO::API::AssociationHelpers.register_resource(self, :body_part)

    # (see ContextIO#api)
    attr_reader :api, :message, :type, :charset, :delsp, :format, :content,
                :body_section

    # @private
    #
    # For internal use only. Users of this gem shouldn't be calling this
    # directly.
    #
    # @param [API] api A handle on the Context.IO API.
    # @param [Hash{String, Symbol => String, Numeric, Boolean}] options A Hash
    #   of attributes describing the resource.
    def initialize(api, options = {})
      @api = api
      @message = options.delete(:message) || options.delete('message')

      options.each do |key, value|
        instance_variable_set("@#{key}", value)

        unless self.respond_to?(key)
          define_singleton_method(key) do
            instance_variable_get("@#{key}")
          end
        end
      end
    end

    def html?
      type == 'text/html'
    end

    def plain_text?
      type == 'text/plain'
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
contextio-1.3.0 lib/contextio/body_part.rb
contextio-1.2.4 lib/contextio/body_part.rb
contextio-1.2.3 lib/contextio/body_part.rb
contextio-1.2.2 lib/contextio/body_part.rb
contextio-1.2.1 lib/contextio/body_part.rb
contextio-1.2.0 lib/contextio/body_part.rb
contextio-1.1.0 lib/contextio/body_part.rb
contextio-1.0.1 lib/contextio/body_part.rb
contextio-1.0.0 lib/contextio/body_part.rb