Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Introspection #118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

teliosdev
Copy link
Contributor

Adds .description to Curly::Presenter, as well as .presenter_for?. Noice. Fixes #105.

{
  components: [
    { name: "midget",
      type: "value",
      attributes: [],
      identifier: nil,
      block: false },
    { name: "clown",
      type: "value",
      attributes: [],
      identifier: nil,
      block: false },
    { name: "elephant",
      type: "value",
      attributes: [],
      identifier: nil,
      block: false },

    { name: "alpha",
      type: "value",
      attributes: [
        { name: "age", required: false }],
      identifier: { name: "name", required: true },
      block: false },

    { name: "beta",
      type: "value",
      attributes: [
        { name: "test", required: true },
        { name: "this", required: false }],
      identifier: nil,
      block: false },

    { name: "charlie",
      type: "value",
      attributes: [],
      identifier: nil,
      block: "test" },

    { name: "delta?",
      type: "conditional",
      attributes: [],
      identifier: nil,
      block: false },
    { name: "cats",
      type: "collection",
      attributes: [],
      identifier: nil,
      block: false },
    { name: "monkey",
      type: "context",
      attributes: [],
      identifier: nil,
      block: false }
  ]
}

@dasch
Copy link
Contributor

dasch commented Nov 17, 2014

❤️

A few comments:

  1. Parameters are called attributes in the Curly nomenclature, and they're always keyword based.
  2. The one positional argument a component may have is the identifier. These should appear separately in the output.
  3. Should the output include recursive descriptions of context and collection blocks? Maybe that's a bad idea, since you don't always want it, and there could be circular references.

@teliosdev
Copy link
Contributor Author

Yeah, I'd say instead of that just put the class name and have the developer get that information if they want to.

@dasch
Copy link
Contributor

dasch commented Nov 17, 2014

I'd rather keep the output at one conceptual level – either use the Curly lingo (components, identifiers, attributes, ...) or the Ruby lingo (methods, arguments, classes).

@teliosdev
Copy link
Contributor Author

Modified the output to separate parameters into keywords, identifier, and block.

Adds a #description method to Curly::Presenter that returns
information about the components that the presenter has
available.  Also adds a #presenter_for? method that looks
for a presenter, if it exists, and returns true if it does.
@teliosdev
Copy link
Contributor Author

That should be it, let me know if there's anything that needs fixing.

@dasch
Copy link
Contributor

dasch commented Nov 24, 2014

Thanks! We've in the process of adding stuff related to this to our product, so I'll probably wait with merging until we've verified that the format is useful. Is it okay if I add commits to this branch if need be?

@teliosdev
Copy link
Contributor Author

Yes; let me know if there is anything I need to do.

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.

Allow introspecting a presenter
2 participants