{"push_id":553566809,"size":1,"distinct_size":1,"ref":"refs/heads/dsl-resources","head":"fcb15801a9e03af527dc54e8773b04b7ffcba089","before":"50bf4aeef6129156d302abbb00194ad745c1e599","commits":[{"sha":"fcb15801a9e03af527dc54e8773b04b7ffcba089","author":{"email":"d5ed6ce43653d1dd9d93c0f8e826e7a0740d63b7@oregonstate.edu","name":"Tom Johnson"},"message":"Extend Mapping DSL with record access\n\nAdds functionality to the mapping DSL for creating instances of a\nresource class from each of a given parser node's values and for\naccessing parsed values in a more human readable fashion.\n\nCreates a RecordProxy in the mapping DSL context. The special DSL method\nchain, with method names, their arguments (and blocks to pass through)\nwhich will be called against the parsed record (via ValueArray) when the\nrecord is processed. RecordProxy mimics Proc in that it has #call and\nsame.\n\nAdds a ValueArray, which encapsulates common access patterns for parsed\nrecord nodes. ValueArray's methods return instances of itself, as they\nintended to be chained. E.g.\n\n```ruby\nval.field(:creator).select { |v| v.some_attribute == 'attribute value' }\n```\n\nValueArray should be extended over time to wrap more of Array's\nfunctionality and capture any emerging patterns.\n\nLastly, this enhances ChildDeclaration to accept optional :each and :as\noptions. These options specify that an instance of the requested child\nclass will be created for each value in the Proc (or RecordProxy) passed\nto :each, and that the matching values will be accessible as a method\nregistered in the block's scope with the name passed to :as.\n\n```ruby\nKrikri::Mapper.define(:esdn_mods) do\n  sourceResource :class => DPLA::MAP::SourceResource do\n    contributor :class => DPLA::MAP::Agent, :each => record.field('mods:name').select { |name| name['mods:role'].map(&:value).include?('contributor') }, :as => :contrib do\n      providedLabel contrib.field('mods:namePart')\n    end\n\n    creator :class => DPLA::MAP::Agent, :each => record.field('mods:name').select { |name| name['mods:role'].map(&:value).include?('creator') }, :as => :creator_role do\n      providedLabel creator_role.field('mods:namePart')\n    end\n end\nend\n```","distinct":true,"url":"https://api.github.com/repos/dpla/KriKri/commits/fcb15801a9e03af527dc54e8773b04b7ffcba089"}]}