curly icon indicating copy to clipboard operation
curly copied to clipboard

Basic Introspection

Open teliosdev opened this issue 11 years ago • 7 comments

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 }
  ]
}

teliosdev avatar Nov 15 '14 21:11 teliosdev

:heart:

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.

dasch avatar Nov 17 '14 10:11 dasch

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

teliosdev avatar Nov 17 '14 11:11 teliosdev

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).

dasch avatar Nov 17 '14 12:11 dasch

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

teliosdev avatar Nov 22 '14 02:11 teliosdev

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

teliosdev avatar Nov 22 '14 02:11 teliosdev

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?

dasch avatar Nov 24 '14 10:11 dasch

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

teliosdev avatar Nov 24 '14 15:11 teliosdev