pachadotdev / analogsea

Digital Ocean R client
https://pacha.dev/analogsea/
Apache License 2.0
154 stars 24 forks source link

Domain record question #85

Closed sckott closed 9 years ago

sckott commented 9 years ago

@hadley Curious why this is the way it is, Thoughts?

as.domain_record.list <- function(x, domain) {
  x <- list_to_object(x, "domain_record", name = NULL)
  if (inherits(x, "domain_record")) {
    x$domain <- domain
    x
  } else {
    lapply(x, function(y) {
      y$domain <- domain
      domain
    })
  }
}

Why does the lapply() call assign the domain object to each record, then return the domain? Shouldn't we return the domain record (aka y)?

As it is now gives

[[1]]
<domain> sckottdrop.info
  ttl: 1800

[[2]]
<domain> sckottdrop.info
  ttl: 1800

[[3]]
<domain> sckottdrop.info
  ttl: 1800

[[4]]
<domain> sckottdrop.info
  ttl: 1800

[[5]]
<domain> sckottdrop.info
  ttl: 1800

[[6]]
<domain> sckottdrop.info
  ttl: 1800

But with the lapply() call returning y we get

[[1]]
<domain_record> 2192415
  NS NS2.DIGITALOCEAN.COM.

[[2]]
<domain_record> 2192416
  NS NS3.DIGITALOCEAN.COM.

[[3]]
<domain_record> 2194418
  TXT "hey there"

[[4]]
<domain_record> 2714618
  TXT "just chillin"

[[5]]
<domain_record> 2714621
  TXT "just chillin"

[[6]]
<domain_record> 2714634
  TXT "the heck"
hadley commented 9 years ago

Yes, I'd say that's just a think-o.

sckott commented 9 years ago

a think-o?

hadley commented 9 years ago

Like a typo, but with your brain, not your fingers.

sckott commented 9 years ago

ah, right