Skip to content

Commit

Permalink
Rename to SerializeAttributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Campbell authored and nickcampbell18 committed Dec 16, 2021
1 parent f5dc107 commit 27fdcb6
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 31 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- image: cimg/postgres:14.1
environment:
POSTGRES_USER: circleci
POSTGRES_DB: serialized_attributes_test
POSTGRES_DB: serialize_attributes_test
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust

Expand Down Expand Up @@ -55,12 +55,12 @@ jobs:
- checkout
- run:
name: Build package
command: gem build serialized_attributes.gemspec
command: gem build serialize_attributes.gemspec
- run:
name: Push package
command: |
VERSION=$(ruby -r "./lib/serialized_attributes/version.rb" -e "print SerializedAttributes::VERSION")
gem push serialized_attributes-${VERSION}.gem
VERSION=$(ruby -r "./lib/serialize_attributes/version.rb" -e "print SerializeAttributes::VERSION")
gem push serialize_attributes-${VERSION}.gem
workflows:
default:
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
serialized_attributes (0.1.0)
serialize_attributes (0.1.0)
activemodel (>= 6)

GEM
Expand Down Expand Up @@ -175,7 +175,7 @@ DEPENDENCIES
rake
rubocop
rubocop-rails
serialized_attributes!
serialize_attributes!

BUNDLED WITH
2.2.30
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# serialized_attributes
# serialize_attributes

Serialize ActiveModel attributes in JSON using type casting:

Expand All @@ -24,7 +24,7 @@ Add `serialized_atributes` to your Gemfile:
$ bundle add serialized_atributes
```

Next, include `SerializedAttributes` in your model class (or `ApplicationRecord` if you want to make
Next, include `SerializeAttributes` in your model class (or `ApplicationRecord` if you want to make
it available everywhere). Your model should have a JSON (or JSONB) attribute, for example
this one is called `settings`:

Expand All @@ -38,7 +38,7 @@ Then, tell the model what attributes we'll be storing there:

```ruby
class MyModel < ActiveRecord::Base
include SerializedAttributes
include SerializeAttributes

serialize_attributes :settings do
attribute :user_name, :string
Expand Down Expand Up @@ -125,7 +125,7 @@ It's also possible to use this library without `ActiveRecord`:
class MyModel
include ActiveModel::Model
include ActiveModel::Attributes
include SerializedAttributes
include SerializeAttributes

# ActiveModel doesn't include a native Hash type, we can just use the Value
# type here for demo purposes:
Expand Down
12 changes: 6 additions & 6 deletions lib/serialized_attributes.rb → lib/serialize_attributes.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# frozen_string_literal: true

require "serialized_attributes/version"
require "serialized_attributes/store"
require "serialize_attributes/version"
require "serialize_attributes/store"

# Serialize ActiveModel attributes in JSON using type casting
module SerializedAttributes
module SerializeAttributes
extend ActiveSupport::Concern

class_methods do
# Configure a SerializedAttributes::Store, using the given column to store each
# Configure a SerializeAttributes::Store, using the given column to store each
# attribute.
#
# class Person
Expand All @@ -25,7 +25,7 @@ def serialize_attributes(column_name, &block)
@serialized_attribute_stores[column_name] = Store.new(self, column_name, &block)
end

# Retrieve a SerializedAttributes registered against the given column
# Retrieve a SerializeAttributes registered against the given column
#
# Person.serialized_attributes_store(:settings)
def serialized_attributes_store(column_name)
Expand All @@ -40,7 +40,7 @@ def serialized_attribute_names(column_name)
end
end

# Retrieve all of the SerializedAttributes attributes, including their default values
# Retrieve all of the SerializeAttributes attributes, including their default values
#
# person = Person.new
# person.serialized_attributes_on(:settings)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module SerializedAttributes
# SerializedAttributes::Store is the individual store, keyed by name. You can get a
module SerializeAttributes
# SerializeAttributes::Store is the individual store, keyed by name. You can get a
# reference to the store by calling `Model.serialized_attributes_store(column_name)`.
class Store
def initialize(model_class, column_name, &block) # :nodoc:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SerializedAttributes
module SerializeAttributes
VERSION = "0.1.0"
end
12 changes: 6 additions & 6 deletions serialized_attributes.gemspec → serialize_attributes.gemspec
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# frozen_string_literal: true

require_relative "lib/serialized_attributes/version"
require_relative "lib/serialize_attributes/version"

Gem::Specification.new do |spec|
spec.name = "serialized_attributes"
spec.version = SerializedAttributes::VERSION
spec.name = "serialize_attributes"
spec.version = SerializeAttributes::VERSION
spec.authors = ["Zaikio"]
spec.email = ["support@zaikio.com"]
spec.homepage = "https://github.com/zaikio/serialized_attributes"
spec.homepage = "https://github.com/zaikio/serialize_attributes"
spec.summary = "Serialize ActiveModel attributes in JSON using type casting"
spec.license = "MIT"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/zaikio/serialized_attributes"
spec.metadata["changelog_uri"] = "https://github.com/zaikio/serialized_attributes/blob/main/CHANGELOG.md"
spec.metadata["source_code_uri"] = "https://github.com/zaikio/serialize_attributes"
spec.metadata["changelog_uri"] = "https://github.com/zaikio/serialize_attributes/blob/main/CHANGELOG.md"

spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]

Expand Down
Binary file added serialized_attributes-0.1.0.gem
Binary file not shown.
2 changes: 1 addition & 1 deletion test/dummy/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true

include SerializedAttributes
include SerializeAttributes
end
2 changes: 1 addition & 1 deletion test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require "serialized_attributes"
require "serialize_attributes"

module Dummy
class Application < Rails::Application
Expand Down
4 changes: 2 additions & 2 deletions test/dummy/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ default: &default

development:
<<: *default
database: serialized_attributes_development
database: serialize_attributes_development

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: serialized_attributes_test
database: serialize_attributes_test
4 changes: 2 additions & 2 deletions test/serialized_attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "test_helper"

class SerializedAttributesTest < ActiveSupport::TestCase
class SerializeAttributesTest < ActiveSupport::TestCase
test "loading and reloading a complex model" do
record = MyModel.create!(normal_column: "yes", data: { "booly" => false, "stringy" => "present" })

Expand Down Expand Up @@ -54,7 +54,7 @@ def secret
local = Class.new do
include ActiveModel::Model
include ActiveModel::Attributes
include SerializedAttributes
include SerializeAttributes

attribute :settings, ActiveModel::Type::Value.new

Expand Down

0 comments on commit 27fdcb6

Please sign in to comment.