Sha256: bff4b55064697719a45816d1fe55f89030e83200a76541734e0c7ba96baf927b

Contents?: true

Size: 707 Bytes

Versions: 6

Compression:

Stored size: 707 Bytes

Contents

# - in ApplicationApi, class level
# api_attr :secure_token do |name|
#   error 'User session required' unless User.current
#   error 'Secure token not found' unless params[:secure_token]
#   error 'Invalid secure token' if User.current.secure_token(name) != params.delete(:secure_token)
# end

# - in object api, instance level
# secure_token :delete
# def delete_me
#   'ok'
# end

class ApplicationApi
  API_ATTR ||= {}

  def self.api_attr name, &block
    method_attr name

    API_ATTR[name] = block
  end

  ## api_attr check
  before do
    for method_attr_name, block in API_ATTR
      for data in @method_attr[method_attr_name].or([])
        instance_exec data, &block
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lux-fw-0.5.37 ./plugins/api/lib/attr.rb
lux-fw-0.5.36 ./plugins/api/lib/attr.rb
lux-fw-0.5.35 ./plugins/api/lib/attr.rb
lux-fw-0.5.34 ./plugins/api/lib/attr.rb
lux-fw-0.5.33 ./plugins/api/lib/attr.rb
lux-fw-0.5.32 ./plugins/api/lib/attr.rb