Sha256: 3fe4481811bb6dea2f3cd3515708c3dbb802074bff4cdeec83f238da2d44f6b9

Contents?: true

Size: 775 Bytes

Versions: 27

Compression:

Stored size: 775 Bytes

Contents

module Wordnik

  class Endpoint
    require 'active_model'
    include ActiveModel::Validations
    include ActiveModel::Conversion
    extend ActiveModel::Naming

    attr_accessor :path, :description, :operations, :resource

    validates_presence_of :path, :description, :operations

    def initialize(resource, attributes = {})
      self.resource = resource
      
      attributes.each do |name, value|
        send("#{name.to_s.underscore.to_sym}=", value)
      end

      # Generate Operations instances from JSON
      if self.operations
        self.operations = self.operations.map do |operationData|
          Operation.new(self, operationData)
        end
      end
    end

    # It's an ActiveModel thing..
    def persisted?
      false
    end

  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
wordnik-4.12 lib/wordnik/endpoint.rb
wordnik-4.11 lib/wordnik/endpoint.rb
wordnik-4.10 lib/wordnik/endpoint.rb
wordnik-4.09 lib/wordnik/endpoint.rb
wordnik-4.08 lib/wordnik/endpoint.rb
wordnik-4.07 lib/wordnik/endpoint.rb
wordnik-4.06.15 lib/wordnik/endpoint.rb
wordnik-4.06.14 lib/wordnik/endpoint.rb
wordnik-4.06.13 lib/wordnik/endpoint.rb
wordnik-4.06.12 lib/wordnik/endpoint.rb
wordnik-4.06.11 lib/wordnik/endpoint.rb
wordnik-4.06.10 lib/wordnik/endpoint.rb
wordnik-4.06.08 lib/wordnik/endpoint.rb
wordnik-4.06.07 lib/wordnik/endpoint.rb
wordnik-4.06.06 lib/wordnik/endpoint.rb
wordnik-4.06.05 lib/wordnik/endpoint.rb
wordnik-4.06.04 lib/wordnik/endpoint.rb
wordnik-4.06.02 lib/wordnik/endpoint.rb
wordnik-4.06.01 lib/wordnik/endpoint.rb
wordnik-4.06.00 lib/wordnik/endpoint.rb