Project

mc_record

0.0
No release in over a year
MicroCMS API's ORM like ActiveRecord for Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

 Project Readme

McRecord

McRecord is an ORM for MicroCMS API like ActiveRecord written in Ruby.

https://document.microcms.io/content-api/get-list-contents

Usage

Configure MicroCMS API

Configure MicroCMS to use API. https://document.microcms.io/manual/create-api

Installation

Create a Gemfile like below, and bundle install.

gem "mc_record"

Implementation

Create a Ruby source file like below.

require "mc_record"

# Credentials
McRecord::Base.config(
  service_domain: "[Domain Name]",
  api_key: "[API Key]",
  end_point: "[End Point]"
)

# Define a class that inherits `McRecord::Base`
class Content < McRecord::Base
end

# Examples
content = Content.find("[ID]") # => Content

# MicroCMS API fields can be read/written as attributes of defined classes.
puts content.name
content.category = ""

# Other Methods.
Content.all # => Array<Content>
Content.where(category: "[Name of Category]") # => Array<Content>

Supported features

The following methods are supported.

  • all
  • find
  • where

Future Issues.

It looks like Active Record, but doesn't offer the complexities of Active Record::Relation. For example, it does not support method chaining, lazy loading, etc.