Skip to content

Define remote methods via model settings/config - #1366

Merged
bajtos merged 1 commit into
masterfrom
feature/remote-methods-in-json
May 12, 2015
Merged

Define remote methods via model settings/config#1366
bajtos merged 1 commit into
masterfrom
feature/remote-methods-in-json

Conversation

@bajtos

@bajtos bajtos commented May 6, 2015

Copy link
Copy Markdown
Member

Process settings.methods and config.methods as a key-value map
where the key is the method name and the value is an object describing
the method in the format expected by strong-remoting.

Example: a static method Model.create

"methods": {
  "create": {
    "isStatic": true,
    "accepts": {
       "arg": "data", "type": "Car",
       "http": { "source": "body" }
    },
    "returns": { "arg": "data", "type": "Car", "root": true }
  }
}

This patch is a reworked version of #1163 and fixes #209 .

/to @ritch please review
/cc @mrfelton

Comment thread lib/registry.js

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to report a warning instead of throwing an exception, because what if somebody was already using the "methods" option and implemented a solution similar to this patch? Throwing an exception would break backwards-compatibility for that case.

However, if you @ritch think I am too cautious and it's ok to throw an error, then I'll rework this part.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what you have is fine...

@ritch

ritch commented May 6, 2015

Copy link
Copy Markdown
Member

@mrfelton thanks for the original contribution. We appreciate you moving this forward 👍 👍 👍

@mrfelton

mrfelton commented May 6, 2015

Copy link
Copy Markdown
Contributor

no worries... Will be great to see this finally committed in some form. I'm for the backwards compatibility option of providing a warning rather than throwing an exception, since I am using my earlier path on several systems :)

Process `settings.methods` and `config.methods` as a key-value map
where the key is the method name and the value is an object describing
the method in the format expected by strong-remoting.

Example: a static method `Model.create`

    "methods": {
      "create": {
        "isStatic": true,
        "accepts": {
           "arg": "data", "type": "Car",
           "http": { "source": "body" }
        },
        "returns": { "arg": "data", "type": "Car", "root": true }
      }
    }

This patch is based on the code proposed by @mrfelton in #1163.
@bajtos
bajtos force-pushed the feature/remote-methods-in-json branch from 35db170 to f93b69e Compare May 7, 2015 05:43
@bajtos

bajtos commented May 7, 2015

Copy link
Copy Markdown
Member Author

@ritch LGTY now?

@ritch

ritch commented May 7, 2015

Copy link
Copy Markdown
Member

LGTM 👍

@ritch ritch assigned bajtos and unassigned ritch May 7, 2015
bajtos added a commit that referenced this pull request May 12, 2015
Define remote methods via model settings/config
@bajtos
bajtos merged commit 019488f into master May 12, 2015
@bajtos bajtos removed the #review label May 12, 2015
@bajtos
bajtos deleted the feature/remote-methods-in-json branch May 12, 2015 15:32
@gausie

gausie commented Dec 14, 2015

Copy link
Copy Markdown
Contributor

This should be reflected in the docs!

@bajtos

bajtos commented Dec 14, 2015

Copy link
Copy Markdown
Member Author

This should be reflected in the docs!

Good catch, /cc @crandmck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote methods mapping in JSON

4 participants