Sha256: 90b2b94e588f47aa6f2a5f935409ae2da848b7fb5a7ea11234136e3b6a7dfbe3
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
module Relax class Action include Contextable attr_reader :name def initialize(endpoint, name, options, &block) @endpoint = endpoint @name = name @options = options extend_context(endpoint) parse_url_parameters context.evaluate(&block) if block_given? end def execute(values, options, *args) args.unshift(values) if values instance = Instance.new(options, *args) response = performer(instance, options).perform context.parse(response) end def method @options[:method] || :get end private :method def url [@endpoint.url, @options[:url]].join end private :url def performer(instance, options) values = instance.values(context) Performer.new(method, url, values, options) end private :performer def parse_url_parameters url.scan(/(?:\:)([a-z_]+)/).flatten.each do |name| defaults do parameter name.to_sym, :required => true end end end private :parse_url_parameters end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
tylerhunt-relax-0.1.2 | lib/relax/action.rb |
tylerhunt-relax-0.1.3 | lib/relax/action.rb |
relax-0.1.3 | lib/relax/action.rb |
relax-0.1.2 | lib/relax/action.rb |