Popularity
1.5
Stable
Activity
0.0
Stable
1
3
0
Programming language: Crystal
License: MIT License
Tags:
Misc
Latest version: v0.1.2
metaclass alternatives and similar shards
Based on the "Misc" category.
Alternatively, view metaclass alternatives based on common mentions on social networks and blogs.
-
sentry
Build/Runs your crystal application, watches files, and rebuilds/restarts app on file changes -
burocracia.cr
👔 Zero-dependency Crystal shard to validate, generate and format Brazilian burocracias (CPF, CNPJ, CEP) -
wikicr
Wiki in crystal, using Markdown and Git, inspired by dokuwiki. Last features to build are pretty hard, if you have some time to help... :) -
defined
This shard provides facilities for checking whether a constant exists at compile time, and for a variety of different conditional compilation options. Code can be conditionally compiled based on the existence of a constant, version number constraints, or whether an environment variable is set truthy or not.
InfluxDB - Purpose built for real-time analytics at any scale.
InfluxDB Platform is powered by columnar analytics, optimized for cost-efficient storage, and built with open data standards.
Promo
www.influxdata.com
Do you think we are missing an alternative of metaclass or a related project?
README
Metaclass
A Crystal library for manipulating class-level definitions.
Installation
Add this to your application's shard.yml
:
dependencies:
metaclass:
github: mosop/metaclass
Features
Class Property
require "metaclass/object"
class Misc
metaclass!
class_getter faces = {:smile => ":)", :frown => ":("}
class_setter passcode = Random.rand(10000)
class_property movie = "Jaws"
end
Misc.faces # => {:smile => ":)", :frown => ":("}
Misc.faces = {:smile => ":D", :frown => ":{"} # raises error (getter only)
Misc.passcode = Random.rand(10000)
Misc.passcode # raises error (setter only)
Misc.movie # => "Jaws"
Misc.movie = "La Strada"
Misc.movie # => "La Strada"
Predicate
require "metaclass/object"
class Misc
metaclass!
class_getter? exists = true
class_setter? promise_broken = false
class_property? happy = false, neg: unhappy
end
Misc.exists? # => true
Misc.exists! # => raises error (getter only)
Misc.promise_broken!
Misc.promise_broken? # raises error (setter only)
Misc.happy? # => false
Misc.happy!
Misc.happy? # => true
Misc.unhappy!
Misc.happy? # => false
Computed Property
require "metaclass/object"
class Constant
metaclass!
class_getter uuid : String { SecureRandom.uuid }
end
class Inconstant
metaclass!
class_getter uuid : String, memo: false { SecureRandom.uuid }
end
Constant.uuid == Constant.uuid # => true
Inconstant.uuid != Inconstant.uuid # => true
Variable Inheritance
require "metaclass/object"
class A
metaclass!
class_getter inheritance, Hash(Symbol, String) do
{:a => "a"}
end
end
class B < A
metaclass!
inherited_class_getter inheritance do |parent|
parent.merge(:b => "b")
end
end
A.inheritance # => {:a => "a"}
B.inheritance # => {:a => "a", :b => "b"}
Usage
require "metaclass/object"
class A
metaclass!
end
Or more clean:
require "metaclass"
class A
Metaclass.metaclass!
end
And see Features
Release Notes
- v0.1.1
- Predicate
Contributing
- Fork it ( https://github.com/mosop/metaclass/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- mosop - creator, maintainer